Jump to content

Search Code


june_c21

Recommended Posts

i got error when i run this lines of code.

mysql_fetch_array(): supplied argument is not a valid MySQL result

mysql_num_rows(): supplied argument is not a valid MySQL result

$data = mysql_query("SELECT title FROM drawings WHERE upper($field) LIKE'%$find%'"); 
echo "<table border=3 align=center width=100%>";

while($result = mysql_fetch_array( $data )) 
//And we display the results 
{ 
echo "<tr><td align=center>" . $myrow1[0] . "</td></tr>";
} 

//This counts the number or results - and if there wasn't any it gives them a little message explaining that 
$anymatches =mysql_num_rows($data); 
if ($anymatches == 0) 
{ 
echo "Sorry, but we can not find an entry to match your query<br><br>"; 
} 

Link to comment
https://forums.phpfreaks.com/topic/96256-search-code/
Share on other sites

usually you would do something like this

replace "FIELDNAMEHERE" with the field you want to display

and also make sure $field is difined

$result = mysql_query("SELECT title FROM drawings WHERE UPPER($field) LIKE'%$find%'"); 
echo "<table border=3 align=center width=100%>";

while($row = mysql_fetch_array( $result)) 
//And we display the results 
{ 
echo "<tr><td align=center>" . $row['FIELDNAMEHERE'] . "</td></tr>";
} 
//This counts the number or results - and if there wasn't any it gives them a little message explaining that 
$anymatches =mysql_num_rows($result); 
if ($anymatches == 0) 
{ 
echo "Sorry, but we can not find an entry to match your query<br><br>"; 
} 

Link to comment
https://forums.phpfreaks.com/topic/96256-search-code/#findComment-492743
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.