Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

From a HTML submit button my php only uses one variable??

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello all,
I am new to PHP & MYSQL, so may I please have some help?
I am using a HTML submit button to enter 2 variables into php. I can get it working with one variable but when I try to use the 2 it appears that it doesn't like to accept the second to do the SQL query. I have a feeling that it is my syntax but I havn't nailed the problem yet.The code is as follows....
<html>
<body>
<?php
$db = mysql_connect(&quot;localhost&quot;, &quot;root&quot;);
mysql_select_db(&quot;mydb&quot;,$db); //selects database
// This prints the last name depending on the address you type in. &quot;last&quot;
// and &quot;address&quot; are columns in the MYSQL database.
if ($submit)
{
$result = mysql_query(&quot;SELECT * FROM employees WHERE $column like '%$bit%'&quot;,$db);
$myrow = mysql_fetch_array($result);
printf($myrow[&quot;last&quot;]);
}
?>
</ This is the search button />
<form method=&quot;post&quot; action=&quot;<?php echo $PHP_SELF?>&quot;>
Search by - <input type=&quot;Text&quot; name=&quot;column&quot; value=&quot;<?php echo $column ?>&quot;>
for <input type=&quot;Text&quot; name &quot;bit&quot; value=&quot;<?php echo $bit ?>&quot;>
<input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Enter information&quot;>
</form>
</body>
</html>
regards,
Dion
 
it seems that there's a = missing here :
for <input type=&quot;Text&quot; name &quot;bit&quot; value=&quot;<?php echo $bit ?>&quot;>

if it's not that obvious, as i'm new as well i can't really help ... maybe &quot;colum&quot; is a reserved word ??
 
I am probably just as new as you to PHP, but the only thing that I can see is within your [tt]mysql_connect()[/tt] command. I am not 100% sure, but whenever I have used [tt]mysql_connect[/tt] command, I have to pass the localhost, the username and the password of my mySQL server. It appears as if root is just your user name and you are not passing your password. Other than that, I agree with what iza said.

Hope this helps.

-Vic

vic cherubini
malice365@hotmail.com
====

Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director

Wants to Know: Java, Cold Fusion, Tcl/TK

====
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top