triphis Posted October 1, 2003 Share Posted October 1, 2003 Okay, I have a MySQL table, used to keep track of items I have in a collection. When I add a new item to my collection, I go to the \"add.php\" page: [php:1:3d60dc8dc8]<?php $q=\"SELECT * FROM r99 WHERE have=0 ORDER BY name ASC\"; $result = mysql_query($q,$db); while ($row = mysql_fetch_array($result)) { $name = $row[\"name\"]; ?> <form action=\"form.php?name=<?=$name?>\" method=\"post\"> <table width=300 border=0> <tr> <td width=\"150\"><font face=\"verdana\" size=\"1\"><?=$name?></td> <td><input type=\"text\" name=\"paid\" size=15></td> <td> <input type=\"submit\" name=\"submit\" value=\"Go!\"> </td> </tr></table><br></form> <?php } ?> [/php:1:3d60dc8dc8] This is sent to the form.php page like this: form.php?name=$name [php:1:3d60dc8dc8]<?php $connection = mysql_connect(\"$hostname\" , \"$user\" , \"$pass\"); $db = mysql_select_db($dbase , $connection); $q=\"UPDATE r99 SET have=\'1\' WHERE name=\'$name\'\"; $result= mysql_query($q, $connection) or die (\"Could not execute query : $q.\" . mysql_error()); mysql_free_result() $q=\"UPDATE r99 SET paid=\'$paid\' WHERE name=\'$name\'\"; $result= mysql_query($q, $connection) or die (\"Could not execute query : $q.\" . mysql_error()); mysql_free_result() ?>[/php:1:3d60dc8dc8] If you notice, the add php calls up items with HAVE=0 meaning I do not have it. Once it goes through the form page, it is set to 1 (so it won\'t appear on the add.php page again), and the price is added (which was formerly 0) I get this error : Parse error: parse error in /data/members/free/tripod/uk/t/r/i/triphis/htdocs/form.php on line 17 --- which refers to [php:1:3d60dc8dc8]$q=\"UPDATE r99 SET paid=\'$paid\' WHERE name=\'$name\'\";[/php:1:3d60dc8dc8] Where have I gone wrong? Thanx Quote Link to comment https://forums.phpfreaks.com/topic/1092-retrieving-variable-problem-script-posted/ Share on other sites More sharing options...
shivabharat Posted October 2, 2003 Share Posted October 2, 2003 Try this <?php $connection = mysql_connect("$hostname" , "$user" , "$pass"); $db = mysql_select_db($dbase , $connection); $q="UPDATE r99 SET have=\'1\' WHERE name=\'$name\'"; $result= mysql_query($q, $connection) or die ("Could not execute query : $q." . mysql_error()); mysql_free_result(); $q="UPDATE r99 SET paid=\'$paid\' WHERE name=\'$name\'"; $result= mysql_query($q, $connection) or die ("Could not execute query : $q." . mysql_error()); mysql_free_result(); Quote Link to comment https://forums.phpfreaks.com/topic/1092-retrieving-variable-problem-script-posted/#findComment-3736 Share on other sites More sharing options...
triphis Posted October 2, 2003 Author Share Posted October 2, 2003 that worked! thank you Quote Link to comment https://forums.phpfreaks.com/topic/1092-retrieving-variable-problem-script-posted/#findComment-3747 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.