You are here: Re: MySQL PHP problems « PHP Programming Language « IT news, forums, messages
Re: MySQL PHP problems

Posted by Jerry Stuckle on 03/07/06 21:49

Ababo wrote:
> Hi everyone. I've only really just started using php and I've been
> trying to use it in conjunction with mysql. I keep getting an error
> though when trying to access the result set returned by performing a
> query on the database. I've performed queries on the database outwith
> php, and it correctly returned the correct details. Here's the code for
> it:
>
> <?php
> $dbh=mysql_connect ("localhost", "myusername", "mypassword") or die ('I
> cannot connect to the database because: ' . mysql_error());
> mysql_select_db ("ababoc_filmlistings");
>
> $sql = 'SELECT DISTINCT title FROM Listing';
> $rs = mysql_query($sql);
>
> $row = mysql_fetch_row($rs); // line 24
> echo $row[0];
>
> ?>
>
> but I end up with the error:
>
> Warning: mysql_fetch_row(): supplied argument is not a valid MySQL
> result resource in /home/ababoc/public_html/test/index.php on line 24
>
> I'm really not sure what I could be doing wrong here. Any help would be
> much appreciated.
>

Check the results of your mysql_select_db() and mysql_query() calls and
see why one failed.

You should *always* check the results of any call to MySQL and handle
errors appropriately!

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

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

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