search query help

stesouthby

New Member
Messages
115
Reaction score
0
Points
0
hey guys am doing a simple mysql query but keep gettingan error with this part of the php file

while ($row = mysql_fetch_array($sql)){

and this is the error i get i cant work out why wonder if you knew any better?

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in ///l/search.php on line 9


<?php
mysql_connect ("localhost", "","") or die (mysql_error());
mysql_select_db ("");

$company_name = $_POST['company_name'];

$sql = mysql_query("select * from customertable where company_name like '%$company_name%'");

while ($row = mysql_fetch_array($sql)){
echo 'ID: '.$row['customer_ID'];
echo '<br/> First Name: '.$row['company_name'];
echo '<br/> Last Name: '.$row['customer_name'];
echo '<br/> Phone: '.$row['email'];
echo '<br/><br/>';
}
?>
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Here we go again...

 
Last edited:

bdistler

Well-Known Member
Prime Account
Messages
3,534
Reaction score
196
Points
63
See me post in this thread in this forum:

"PHP/SQL: Increment Integer Value in Database via Form"
 
Top