You are here: Re: mysql_fetch_array(): supplied argument is not a valid MySQL result resource « PHP SQL « IT news, forums, messages
Re: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

Posted by strawberry on 11/30/06 00:37

Dan wrote:
> I've been getting this error below:
>
> mysql_fetch_array(): supplied argument is not a valid MySQL result
> resource
>
> When running this code, I can't seem to figure out what is wrong.
>
> <?php
> require_once('functions.php');
>
> $search = $_POST['term'];
> $field = $_POST['field'];
>
> do_html_header();
>
> //query
> $conn = db_connect();
> $result = $conn->query("SELECT city, restaurant FROM massachusetts
> WHERE $field LIKE '%$search%'");
> if (!$result)
> return false;
>
>
> //And we display the results
> while($data = mysql_fetch_array($result))
> {
> echo $data['city'];
> echo " ";
> echo $data['restaurant'];
> echo "<br>";
> echo "<br>";
> }
>
> do_html_sidebar();
> do_html_footer();
>
> ?>
>
> my db_connect(); function is below (with the login information
> changed):
>
> function db_connect()
> {
> $result = new mysqli('localhost', 'user', 'password', 'database');
> if (!$result)
> throw new Exception('Could not connect to database server');
> else
> return $result;
> }
>
> And this is my search form where it gets the post variables:
>
> <form method='post' action='performsearch.php'>
> <table bgcolor='#cccccc'>
> <tr>
> <td>Search here:</td>
> <td><input type='text' name='term'></td>
> <td><Select NAME="field">
> <Option VALUE="college">college</option>
> <Option VALUE="restaurant">restaurant</option>
> <Option VALUE="phone1">phone</option>
> </Select></td></tr>
> <tr>
> <td colspan=2 align='center'>
> <input type='submit' value='Search'></td></tr>
> </table></form>
>
>
> Can anybody help? Thanks

is 'query' a valid function? perhaps that should be 'mysql_query'?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация