jbrill Posted July 4, 2007 Share Posted July 4, 2007 I am trying to use a form to call another page (search.php) where search.php finds the text enter in the text field from the database and displays it. The problem im having is that I cannot seem to get it working... could some one please look at my code and tell me if it is ok, and if it isn't, help me make it work. My error Im getting is: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/morow/public_html/admin/search.php on line 68 but i think it has to do with the way i query the database....im new to php... Help is much appreciated, this forum is awesome! \\assuming I have already connected tot he database <? echo"<table border=\"0\" width=\"80%\" bgcolor=\"#ffffff\" class=\"MainBody1\" cellpaddin=\"0\" cellspacing=\"0\">"; echo"<tr>"; echo"<td class=\"underline\">Quote Number</td><td class=\"underline\">Job Number</td><td class=\"underline\">PO Number</td><td class=\"underline\">Customer</td><td class=\"underline\">Status</td><td class=\"underline\">Action</td>"; echo"<tr>"; $result = mysql_query("SELECT * FROM jobs WHERE prod_number='".$_GET['prod_number']."'"); while($row = mysql_fetch_array($result)) { echo "<tr><td>" . $row['id'] . "</td><td>" . $row['job_number'] ."</td><td>" . $row['po_number'] . "</td><td>" . $row['customer'] . "</td><td>" . $row['status'] . "</td><td> <a class=\"link\" href=\"admin_modnews.php?idr=".$row['id']."&table=jobs\"><img src=\"images/actionEdit.gif\" border=\"0\"></a> <a class=\"link\" href=\"admin_delete.php?idr=".$row['id']."&table=jobs\"><img src=\"images/actionDelete.gif\" border=\"0\"></a> </td></tr>"; } echo"</table>"; ?> Link to comment https://forums.phpfreaks.com/topic/58441-simple-search-question-from-query/ Share on other sites More sharing options...
redarrow Posted July 4, 2007 Share Posted July 4, 2007 try this please. <?php echo"<table border=\"0\" width=\"80%\" bgcolor=\"#ffffff\" class=\"MainBody1\" cellpaddin=\"0\" cellspacing=\"0\">"; echo"<tr>"; echo"<td class=\"underline\">Quote Number</td><td class=\"underline\">Job Number</td><td class=\"underline\">PO Number</td><td class=\"underline\">Customer</td><td class=\"underline\">Status</td><td class=\"underline\">Action</td>"; echo"<tr>"; $result = mysql_query("SELECT * FROM jobs WHERE like prod_number='%".$_GET['prod_number']."%' "); while($row = mysql_fetch_array($result)) { echo "<tr><td>" . $row['id'] . "</td><td>" . $row['job_number'] ."</td><td>" . $row['po_number'] . "</td><td>" . $row['customer'] . "</td><td>" . $row['status'] . "</td><td> <a class=\"link\" href=\"admin_modnews.php?idr=".$row['id']."&table=jobs\"><img src=\"images/actionEdit.gif\" border=\"0\"></a> <a class=\"link\" href=\"admin_delete.php?idr=".$row['id']."&table=jobs\"><img src=\"images/actionDelete.gif\" border=\"0\"></a> </td></tr>"; } echo"</table>"; ?> Link to comment https://forums.phpfreaks.com/topic/58441-simple-search-question-from-query/#findComment-289793 Share on other sites More sharing options...
jbrill Posted July 4, 2007 Author Share Posted July 4, 2007 still no luck.... got this warning: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/morow/public_html/admin/search.php on line 68 line 68 is: while($row = mysql_fetch_array($result)) Link to comment https://forums.phpfreaks.com/topic/58441-simple-search-question-from-query/#findComment-289799 Share on other sites More sharing options...
redarrow Posted July 4, 2007 Share Posted July 4, 2007 <?php echo"<table border=\"0\" width=\"80%\" bgcolor=\"#ffffff\" class=\"MainBody1\" cellpaddin=\"0\" cellspacing=\"0\">"; echo"<tr>"; echo"<td class=\"underline\">Quote Number</td><td class=\"underline\">Job Number</td><td class=\"underline\">PO Number</td><td class=\"underline\">Customer</td><td class=\"underline\">Status</td><td class=\"underline\">Action</td>"; echo"<tr>"; $result = mysql_query("SELECT * FROM jobs WHERE prod_number like ='%".$_GET['prod_number']."%' "); while($row = mysql_fetch_array($result)) { echo "<tr><td>" . $row['id'] . "</td><td>" . $row['job_number'] ."</td><td>" . $row['po_number'] . "</td><td>" . $row['customer'] . "</td><td>" . $row['status'] . "</td><td> <a class=\"link\" href=\"admin_modnews.php?idr=".$row['id']."&table=jobs\"><img src=\"images/actionEdit.gif\" border=\"0\"></a> <a class=\"link\" href=\"admin_delete.php?idr=".$row['id']."&table=jobs\"><img src=\"images/actionDelete.gif\" border=\"0\"></a> </td></tr>"; } echo"</table>"; ?> Link to comment https://forums.phpfreaks.com/topic/58441-simple-search-question-from-query/#findComment-289805 Share on other sites More sharing options...
jbrill Posted July 4, 2007 Author Share Posted July 4, 2007 still no luck... same error Link to comment https://forums.phpfreaks.com/topic/58441-simple-search-question-from-query/#findComment-289811 Share on other sites More sharing options...
redarrow Posted July 4, 2007 Share Posted July 4, 2007 post the select statement when tried this ok. <?php echo"<table border=\"0\" width=\"80%\" bgcolor=\"#ffffff\" class=\"MainBody1\" cellpaddin=\"0\" cellspacing=\"0\">"; echo"<tr>"; echo"<td class=\"underline\">Quote Number</td><td class=\"underline\">Job Number</td><td class=\"underline\">PO Number</td><td class=\"underline\">Customer</td><td class=\"underline\">Status</td><td class=\"underline\">Action</td>"; echo"<tr>"; $x=$_GET['prod_number']; $result = " SELECT * FROM `jobs` WHERE `prod_number` like ='%$x%' "; $result=mysql_query($result)or die("mysql_error"); echo $result; while($row = mysql_fetch_array($result)) { echo "<tr><td>" . $row['id'] . "</td><td>" . $row['job_number'] ."</td><td>" . $row['po_number'] . "</td><td>" . $row['customer'] . "</td><td>" . $row['status'] . "</td><td> <a class=\"link\" href=\"admin_modnews.php?idr=".$row['id']."&table=jobs\"><img src=\"images/actionEdit.gif\" border=\"0\"></a> <a class=\"link\" href=\"admin_delete.php?idr=".$row['id']."&table=jobs\"><img src=\"images/actionDelete.gif\" border=\"0\"></a> </td></tr>"; } echo"</table>"; ?> Link to comment https://forums.phpfreaks.com/topic/58441-simple-search-question-from-query/#findComment-289813 Share on other sites More sharing options...
jbrill Posted July 4, 2007 Author Share Posted July 4, 2007 still no luck! getting an error in the query still and its the correct way... Link to comment https://forums.phpfreaks.com/topic/58441-simple-search-question-from-query/#findComment-289942 Share on other sites More sharing options...
teng84 Posted July 4, 2007 Share Posted July 4, 2007 is this declaredas char or varchar in your db "prod_number`" the way you wrote it seems like a number number i guess cant use like Link to comment https://forums.phpfreaks.com/topic/58441-simple-search-question-from-query/#findComment-289946 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.