-
Posts
3,404 -
Joined
-
Last visited
-
Days Won
55
Everything posted by Ch0cu3r
-
make $_SESSION["odd"] and $_SESSION["even"] arrays. You can then use array_sum to add up the odd/even numbers together. To list the numbers you can use implode <?php // reset session if(isset($_POST['reset'])) { session_destroy(); unset($_SESSION); } session_start(); $_SESSION["number"] = rand(1,10); // set odd and even sessions to array if(!isset($_SESSION["odd"]) || !isset($_SESSION["even"])) { $_SESSION["odd"] = array(); $_SESSION["even"] = array(); } if(isset($_GET["check"])) { if ($_SESSION["number"] %2 == 0) { $_SESSION["even"][] = $_SESSION["number"]; // even number to array } else { $_SESSION["odd"][] = $_SESSION["number"]; // odd number to array } } $_SESSION["sum"] = array_sum($_SESSION["odd"]) + array_sum($_SESSION["even"]); // add up the odd and even number array's ?> <body> <form action="" method="post"> ODD number: <?php echo implode(',', $_SESSION["odd"]); /* list odd numbers */ ?> <br /> EVEN number: <?php echo implode(',', $_SESSION["even"]); /* list even numbers */ ?><br /> SUM of all the numbers that have appeared:<?php echo $_SESSION["sum"];?><br /> <input type="submit" name="check" value="submit" /> <input type="reset" name="reset" value="Reset" /> </form> </body>
-
Where is the dropdown menu for interest? Also these lines need to be swapped around $intrest = (isset($_POST['intrest']) && $_POST['intrest'] != '') ? $_POST['intrest'] : $serviceLine; $serviceLine = $this->serviceLine; // this should be before the line above
-
mysql_query() does not return any data from the query. it only returns a result resource. To get the data from the query you need to use a function like mysql_fetch_assoc So change echo $run2; $query2 = "insert into complaint(complain,d_name,complainant_id) values ('$complain_det','$comp_name','$run2')"; to $row = mysql_fetch_assoc($run2); // get the data from the query $query2 = "insert into complaint(complain,d_name,complainant_id) values ('$complain_det','$comp_name','{$row['complainant_id']}')";
-
$_SERVER["REMOTE_USER"] blank.. but not really?
Ch0cu3r replied to jgauthier's topic in PHP Coding Help
Then shouldn't you be using $_SERVER["HTTP_USER"] instead of $_SERVER["REMOTE_USER"]? -
Your can create a dropdown using <select> the populate the menu with choices using <option>. Example html <select name="intrest"> <!-- name attribute defines the name of the input --> <option value="">Choose Intrest</option> <option value="value1">Option 1</option> <option value="value2">Option 2</option> <option value="value3">Option 3</option> .. etc </select> If you include that html into your form you should be able to get the selected options value using $_POST['interest']; $intrest = $_POST['intrest']; Using the example code above you could do $intrest = (isset($_POST['intrest']) && $_POST['intrest'] != '') ? $_POST['intrest'] : $serviceLine; // default to $serviceLine if no interest was selected
-
Newbie needing help: Table causes "syntax" error
Ch0cu3r replied to LDMartin1959's topic in PHP Coding Help
Probably. I see Dreamweaber as a WYSIWYG editor for HTML/CSS with a premium price tag, not a IDE for programming. Take notice of what PHP says not your editor. -
Newbie needing help: Table causes "syntax" error
Ch0cu3r replied to LDMartin1959's topic in PHP Coding Help
No the the extra ) belonged to the mysql_fetch_object function. All I did was separate the mysql_query() on to its own line and then checked to make sure the query returned any results before using mysql_fetch_object. The problem was the query was not returning any results. When mysql_fetch_* functions are given an empty result set then you will get this type of error -
Newbie needing help: Table causes "syntax" error
Ch0cu3r replied to LDMartin1959's topic in PHP Coding Help
You are getting that error due to your query not returning any results. Change <?php $row = mysql_fetch_object(mysql_query("select * from wp_posts where ID=".$_GET['id'])); if($row->evtdate=="") { wp_redirect(home_url()); exit; } to <?php $result = mysql_query("select * from wp_posts where ID=".$_GET['id']); if(mysql_num_rows($result)) { $row = mysql_fetch_object($result); if($row->evtdate=="") { wp_redirect(home_url()); exit; } } -
Newbie needing help: Table causes "syntax" error
Ch0cu3r replied to LDMartin1959's topic in PHP Coding Help
Can you post the PHP error messages in full here. Ignore what your editor says. -
Yes I assume that what it means
-
2 collumns 1 hidden pulled from a table HELP!
Ch0cu3r replied to spanner206's topic in PHP Coding Help
Edit oops.... To make a dropdown you need to output a <select> field with <options>'s. $sql = 'SELECT tbl_typesofbusiness.id, tbl_typesofbusiness.Agent FROM tbl_typesofbusiness'; if ($result = mysqli_query($con, $sql)) { echo '<form action="addeadstemplate.php" method="post">'; // start the form echo '<select name="businessAgents">'; // start a dropdown menu while($row = mysqli_fetch_array($result)) { echo '<option value="' . $row['id'] . '>' . $row['testcollumn'] . '</option>'; // add options to the menu } echo '</select>'; // close the dropdown menu echo '<input type="submit" />'; // submit button echo '</form>'; // close the form } -
If this is all on the same page then there is no need to use explode again. Just use $explode[1] to get the town. $ad = $_GET['ad1']; $explode = explode(',', $ad); $street = $explode[0]; $town = $explode[1];
-
These options are explained here http://httpd.apache.org/docs/current/mod/core.html#options
-
Do the regex for code tags first, replacing anything within these tags into htmlentities. That way the bbcode within these tags will not be parseable. // replace code tags first $text = preg_replace_callback("/\[code\](.+?)\[\/code\]/is", function($matches) { return str_replace(array('[', ']'), array('[', ']'), htmlentities($matches[1])); }, $text);
-
This a forum for PHP Help not Javascript
-
Try adding the Date and Range column in backticks `Date`, `Range` These are reserved keywords.
-
Your query values need to be in quotes mysqli_query($con,"INSERT INTO battery (Date, Range, Percent, Sleep) VALUES ('$date', '$miles', $battery_level, 1)");
-
More of a MySQL question than a PHP one. You set all fields to be varchar with a 255 character limit. Which is lazy database design. The data type you set the field to should represent the type of data you are storing in that field. Such as the zipcode, bedrooms and sqft would be numbers so an int datatype would be more suitable. price should be float or decimal datatype. You should rethink how you are setting the table up. http://dev.mysql.com/doc/refman/5.0/en/data-types.html
-
Try customer_information[field] = value;
-
That script you linked to also requires Node.js aswell as PHP. The steps listed in the link tells you how to install it. head over to php.net/manual to learn PHP. You add PHP code between tags (<?php ?>) to add php to a webpage. Make sure the file has a .php extension and that the server is configured with PHP.
-
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean
Ch0cu3r replied to yoyo's topic in PHP Coding Help
What do you mean by this? Is this addtocart($pid,1); supposed to add the product to the database? What is the code for this php function -
Check your browsers JavaScript development console (press F12 and then click console tab). What errors are shown?