Fearpig Posted September 11, 2006 Share Posted September 11, 2006 ???Hi Guys I'm having a few problems with my forms. I have a text box passing a variable using GET to the next page. The address bar has:http://fer-post/test/Spares/Test.php?PartsSearch=39810370so the PartsSearch is there with a value of 39810370.However using the following code I just get the error shown below:[code]$_GET['PartsSearch']$result = mysql_query("SELECT * FROM tbl_parts WHERE Air_Pressure_Switch=$PartsSearch", $db); $row = mysql_fetch_array($result);while ($row = mysql_fetch_array($result)) { printf("<b class='Body2'>%s</b><br>", $row["Model"]); }[/code]Error message:Parse error: parse error, unexpected T_VARIABLE in D:\Intranet v3\TEST\Spares\test.php on line 7(line 7 is the $result line) Can anyone see where I'm going wrong? Link to comment https://forums.phpfreaks.com/topic/20400-i-dont-get-forms/ Share on other sites More sharing options...
wildteen88 Posted September 11, 2006 Share Posted September 11, 2006 Use this:[code=php:0]$PartsSearch = $_GET['PartsSearch'];$result = mysql_query("SELECT * FROM tbl_parts WHERE Air_Pressure_Switch='$PartsSearch'", $db);$row = mysql_fetch_array($result);while ($row = mysql_fetch_array($result)) { printf("<b class='Body2'>%s</b><br>", $row["Model"]);}[/code]From looking at your code, you didnt the define the $PartsSearch variable. However thats not the problem. The problem is where you have $_GET['PartsSearch'] on its own. You didnt add a semi-colon after $_GET['PartsSearch']. Thats why your got the parse error. Link to comment https://forums.phpfreaks.com/topic/20400-i-dont-get-forms/#findComment-89857 Share on other sites More sharing options...
obsidian Posted September 11, 2006 Share Posted September 11, 2006 you're not doing anything at all with this line:[code]<?php$_GET['PartsSearch'];?>[/code]you need to assign the value of that $_GET to the variable you're trying to use in the query or else just use $_GET itself in your query:[code]<?php// either$PartsSearch = $_GET['PartsSearch'];$result = mysql_query("SELECT * FROM tbl_parts WHERE Air_Pressure_Switch=$PartsSearch", $db);// or$result = mysql_query("SELECT * FROM tbl_parts WHERE Air_Pressure_Switch=$_GET[PartsSearch]", $db);?>[/code]hope this helps Link to comment https://forums.phpfreaks.com/topic/20400-i-dont-get-forms/#findComment-89858 Share on other sites More sharing options...
Fearpig Posted September 11, 2006 Author Share Posted September 11, 2006 Corr you two are quick and teaching me loads! ;DI have to be more careful with my code. Thank you both.Tom Link to comment https://forums.phpfreaks.com/topic/20400-i-dont-get-forms/#findComment-89868 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.