-
Posts
3,404 -
Joined
-
Last visited
-
Days Won
55
Everything posted by Ch0cu3r
-
If you are getting that message then it appears the g-recaptcha-response value is not being submitted by your form. Make the google recaptha code is within your <form></form tags and can you confirm there is a g-recaptcha-response value when submitting the form. To see the submitted values add console.log(form.serialize()); after function ajaxSubmit() { - You will need to look at your browsers development console tab to see the logged value returns (press F12 key or right click anywhere on the page select Inspect Element and then select console tab)
-
How to print div or rectangle shape by input value
Ch0cu3r replied to avinashd's topic in PHP Coding Help
Use the style attribute to apply the width and height of the div <div style="width:<?php echo $w; ?>px;height:<?php echo $h; ?>px;background-color:red;border:1px solid #000;"></div> -
That code you posted is connecting to mysql just fine. The error is warning you the the mysql extension (or in other words the mysql_*() functions) are deprecated meaning they are no longer supported and are being removed (on release of PHP7) To use mysql with PHP you need to use either MySQL Improved (mysqli) or PDO (pdo_mysql extension).
-
The ) on line 112 here "'.$Image6.'"';) needs to be before ';, so its "'.$Image6.'")';
-
You say you have amended the changes Barand and Jacques mentioned. Why does the code you posted above not show these changes?
-
Do not use smart quotes “ ” for smpt config. You need to be using normal straight quotes " "
-
alert ('dataString'); is going to alert the string literal "dataString". If you want to display the value of the dataString variable then remove the quotes alert(dataString);
-
how to get or post the value from link to HTML form?
Ch0cu3r replied to sigmahokies's topic in PHP Coding Help
You use $_GET to grab the values from the url - which is called the querystring (the stuff that is after the ?). You cant use $_POST with a link. As BuildMyWeb said $_GET['edit'] will contain the id value from your link. Your next step is to query the database where $_GET['edit'] matches a row with the same id. From the result of the query you then populate your form fields. -
small box at the side of input form show result fetched
Ch0cu3r replied to sungpeng's topic in Javascript Help
Can you be more specific? What is the input box for? What is in your database? -
It you would be helpful if you had posted your code (wrap in tags) and the error messages you are getting
-
In writingOverImage.php you cannot have your html/form and the php code for creating the image in the same file. They must in separate files like so form.php <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Floating window with tabs</title> <style> /* This defines the workspace where i place the demo. */ #container { text-align: left; background: #FFF; width: 865px; margin: 20px auto; padding: 20px; border-left: 1px solid #CCC; border-right: 1px solid #CCC; -moz-box-shadow: 0px 0px 10px #BBB; -webkit-box-shadow: 0px 0px 10px #BBB; box-shadow: 0px 0px 10px #BBB; } </style> </head> <body> <div id="container"> <?php if($_POST["sending"]=="yes"){ if(strlen($_POST["text"]<50)){ echo ' <img id="imgFinal" src="writingOverImage.php?size=50&text='.$_POST["text"].'" /> <img id="imgFinal" src="writingOverImage.php?x=right&y=center&size=30&r=74&g=50&b=170&text='.$_POST["text"].'" /> <img id="imgFinal" src="writingOverImage.php?x=left&y=bottom&size=90&text='.$_POST["text"].'" /> '; } else{ echo "The text is too large for my demo!! "; } } else{ echo ' <img id="imgFinal" src="writingOverImage.php?size=50&text=Hello world!!" /> '; } ?> <form name="formulario" action="" method="post" class="contactoFormulario"> <div class="caja"><input type="text" name="text" />Text you want to write over the image</div> <button class="botonFormulario" type="submit" name="Submit" value="Enviar" />Generate image</button> <input type="hidden" name="sending" value="yes" /> </form> </div> </body> </html> writingOverImage.php <?php require_once 'class.textPainter.php'; $x = $y = $R = $G = $B = null; if(isset($_GET['x'], $_GET['y'])) { $x = $_GET["x"]; $y = $_GET["y"]; } if(isset($_GET['r'], $_GET['g'], $_GET['b'])) { $R = $_GET["r"]; $G = $_GET["g"]; $B = $_GET["b"]; } $size = $_GET["size"]; $text = $_GET["text"]; $img = new textPainter('./imgs/writingOverImage.jpg', $text, './Franklin.ttf', $size); if(!empty($x) && !empty($y)){ $img->setPosition($x, $y); } if(!empty($R) && !empty($G) && !empty($B)){ $img->setTextColor($R,$G,$B); } $img->show(); NOTE: if your are using PHP version 5.3 or newer then your need to make the following changes to class.textPainter,php. Line 78 needs to be changed to imagejpeg($this->img, NULL, $this->jpegQuality); Line 154 needs to be changed to $this->format = preg_replace("/.*\.(.*)$/","\\1",$this->imagePath);
-
Your use of jquery $.post() is incorrect. It needs to be // JQuery $.post arguments: // url , data , callback $.post( "parser/friend_sys.php", { "user": user_f }, function(data) { // data contains the output of friend_sys.php });
-
Here in manage-games.php $Game = $Game->getAll(); while($Game = $Game->getAll()){ You are calling $Game->getAll(), this is calling your getAll method which returns array of results from the query. You are then assigning what is returned by the method to $Game, this will cause $Game to no longer store an instance of the Game object. You then go to call $Game->getAll() in the while the loop. This is where the error is caused because $Game is no longer the Game object, it is only the array of results. What you want to do is this // get array of results from the query $result = $Game->getAll(); // loop over array of results using foreach loop foreach($result as $row) { echo $row['name'] . '<br />'; } When using the databases in the game model you should not use require "include/dbconnect.php"; to use the database. Instead what you should do is pass the database instance when initializing the Game object // connect to database outside the class require "include/dbconnect.php"; // pass the database connection/instance to the Game object on initialization $Game = new Game($db); In the Game class save the database instance as a property in the constructor class Game { private $db; function __construct(PDO $db) { // set database property $this->db = $db; } ... rest of class here ... } Now in the getAll() method $db will need to be changed to $this->db
-
what is the difference between php web and php command line?
Ch0cu3r replied to lobster's topic in PHP Coding Help
I should add to prevent the error, then you need to validate the values the user has entered are numbers and is not zero. If the values pass validation then perform the calculation. Something like <?php if(isset($_POST['calc'])) //Check if the form is submitted { // DO VALIDATION - make sure values are all numeric and are not zero! // - error message will be set if any value does not pass validation // loop through all values foreach($_POST['values'] as $value) { // check to see if value is not numeric or is zero if(!is_numeric($value) || $value == 0) { // set error message $error = 'Values entered must be numbers and cannot be zero'; break; // stop the foreach loop } } //assign variables $a = $_POST['values']['a']; $b = $_POST['values']['b']; $c = $_POST['values']['c']; $result = ''; // only do the calcuation if the $error variable has not been set if(!isset($error)) { //values pass validation you can calculate your equation $d = $b*$b - (4*$a*$c); $x1 = (-$b + sqrt($d)) / (2 * $a); $x2 = (-$b - sqrt($d)) / (2 * $a); $result = "x<sub>1</sub> = {$x1} and x<sub>2</sub> = {$x2}"; } } // echo error message if it is set if(isset($error)) echo "<b>$error</b>"; ?> <form method="post" action=""> Value A: <input type="text" name="values[a]" value="<?php echo isset($a) ? $a : '' ?>" placeholder="Enter Value 'a'" /><br /> Value B: <input type="text" name="values[b]" value="<?php echo isset($b) ? $b : '' ?>" placeholder="Enter Value 'b'" /><br /> Value C: <input type="text" name="values[c]" value="<?php echo isset($c) ? $c : '' ?>" placeholder="Enter Value 'c'" /> <input type="submit" name='calc' value="Calculate" /> </form> <?php // echo the result of the calculation echo $result; ?> -
what is the difference between php web and php command line?
Ch0cu3r replied to lobster's topic in PHP Coding Help
Are you entering any numbers/values into the three text fields, if so what are they? If you are not entering any values then that is why you are getting that error message. -
what is the difference between php web and php command line?
Ch0cu3r replied to lobster's topic in PHP Coding Help
Can you post the errors -
what is the difference between php web and php command line?
Ch0cu3r replied to lobster's topic in PHP Coding Help
If you running the code through the terminal/command line you cannot use HTML. HTML is for the web browser only. The terminal/command line is plain text only. If you want PHP to ask for user to input in the termina/command line you can use readline or have the the user passing the values as arguments when executing the command What do you mean? That code runs perfectly fine for me. If you are using WAMP make sure you are saving your php files in wamps www directory (C:/[path to wamp]/www). Then open your browser and go to http://localhost/your-file.php to run the code. -
It is because PHP is a loosely typed language. Because you are comparing an integer to a string PHP will be converting the strings, "Y" and "TEST" to be integers, which will result in them being truncated to zero. Therefore your if statements always evaluate to true. What you need to use is === which checks whether both values are equal and are of the same type. See the following for reference http://php.net/manual/en/language.types.type-juggling.php http://php.net/manual/en/types.comparisons.php
-
Umm. HTML5 has nothing to do with Ajax - which is JavaScript, using the xmlhttprequest object. Which is supported by most/if not all modern browsers. However not all browsers provide the same api. With JQuery, which is a javascript framework, provides a standard easy to use api allowing our code to work across all major browsers.
-
Have you shortened the code? Because that is not valid PHP code it needs to be while($doing=mysql_fetch_array($sqlq)) { echo '<input type='checkbox' name='checking[]' value="'.$doing["pid"]'" >'; } Also make sure the Javascript code is after the the while loop otherwise if the javascript coded is before then you need to wrap it in $( document ).ready(function() { // javascript code goes here });
-
You send that value by appending it to your data string, eg var dataString='sendcheck='+ checkboxValue + '&isChecked=' + isCheckboxChecked; // alternatively use var dataString = { sendcheck: checkboxValue, isChecked: isCheckboxChecked }; Now in checking1.php you use $_POST['sendcheck'] to get the checkboxValue value, and use $_POST['isChecked'] to get the isCheckboxChecked value
-
You would call your function like any other function $this->ip = getUserIP(); Or if getUserIP is a method for your poll class then it'll be $this->ip = $this->getUserIP();
-
How are you testing/viewing the output of your script? With that line of code see point 3 As there is are multiple observation values then you should be assigning the array with the observation data to $output[] $output[] = array($time[0], $temperature[0], $current[0],$wind[0],); otherwise you are just overwriting previous observation values with the next observation values.This will result in only the last observation values being stored in $output rather than all the observation values.
-
How are you defining the dataString variable used here data:dataString,