You are here: Re: [PHP] Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource « PHP « IT news, forums, messages
Re: [PHP] Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource

Posted by Mark Sargent on 10/30/76 11:14

Hegedűs Balázs wrote:

> Hi all,
>
> ever tried to test if your connection to the database succeeded? maybe
> that's why it shouted that "...not a valid result resource..." msg.
>
> Balazs Hegedus
>
> Mark Sargent wrote:
>
>> Drewcore wrote:
>>
>>> just put a @ symbol before the function calll, eg
>>>
>>> while ($myrow = @mysql_fetch_row($result)) {
>>> etc
>>>
>>>
>>> On 4/25/05, Mark Sargent <powderkeg@snow.email.ne.jp> wrote:
>>>
>>>
>>>> Hi All,
>>>>
>>>> get the following error when calling data from mysql,
>>>>
>>>> *Warning*: mysql_fetch_row(): supplied argument is not a valid MySQL
>>>> result resource in */var/www/html/phpmysqltable.php* on line *36
>>>> *
>>>> Below are snippets of my code,
>>>>
>>>> Line 22: $result = mysql_query("SELECT product_name,
>>>> product_model_number, product_serial_number FROM Products",$db);
>>>> Line 36: while ($myrow = mysql_fetch_row($result)) {
>>>> printf("<tr><td>%s %s</td><td>%s</td><td>%s
>>>> %</td></tr>\n",
>>>> $myrow[1], $myrow[2], $myrow[3]);
>>>>
>>>> I'm following a webmonkey.com tut for php/mysql.
>>>> http://webmonkey.wired.com/webmonkey/99/21/index3a.html
>>>> Cheers.
>>>>
>>>> Mark Sargent.
>>>>
>>>> --
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>>
>>>
>> Hi All,
>>
>> ok, that fixed the error message, thanx, but, no data is being
>> displayed, only the table/row/cells. Database table, Products
>> definitely has at least 1 entry in it. Cheers.
>>
>> Mark Sargent.
>>
>> printf("<tr><td>%s %s</td><td>%s</td><td>%s</td></tr>\n",
>> $myrow[1], $myrow[2], $myrow[3]);
>>
>
Hi All,

yes, succeeded in connecting to the database earlier, with the below code,

<html>



<body>



<?php



$db = mysql_connect("localhost", "root", "pwd omitted");



mysql_select_db("status",$db);



$result = mysql_query("SELECT * FROM Products",$db);



printf("Product Name: %s<br>\n", mysql_result($result,0,"product_name"));



printf("Product Price: %s<br>\n", mysql_result($result,0,"product_price"));



printf("Product Serial Number: %s<br>\n",
mysql_result($result,0,"product_serial_number"));



printf("Product Model Number: %s<br>\n",
mysql_result($result,0,"product_model_number"));



?>



</body>



</html>

Cheers.

Mark Sargent.

 

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

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