A couple of things.

        first: as documented in http://ca3.php.net/mysql_connect, the third
(optional) parameter is supposed to be the password, so if the password
for root has been left blank, this connect statement cannot succeed.  It
may well be the only immediate problem.

        second: I notice that after your connect, the select_db and the query,
you are not checking the return values for errors (which would probably
have turned up item 1 immediately.  Never assume that interactions with
external systems (which the database is) are successful, even if you are
sure the parameters are correct...  there are always a million things
that could go wrong at runtime.  Each of those php mysql_XXX calls will
return a null or false on failure ..  if you check every time you will
save yourself a lot of hassle in the long run,

 - michael dykman
 - [EMAIL PROTECTED]


On Thu, 2006-01-12 at 01:15 +0800, Jon Miller wrote:
> Having an error in a script that I cannot figure out why it's not working.  
> The problem is on line 15  "while ($row = mysql_fetch_object" ($result)).
> 
> Movie Database<BR>
> <pre>
> <?php
>     // Connect to MySQL server
>     // User name is root and password is blank
>     $link = mysql_connect('127.0.0.1','root','mmtnet');
>     // Select the database
>     $db = mysql_select_db("movie_library", $link);
>     // Query the database for all fields from table 'movies'
>     $result = mysql_query("SELECT * FROM movies", $link);
> 
>     // Loop through all the rows
>     while ($row = mysql_fetch_object($result))
>     {
>         // print the object for each row
>         print_r($row);
>     }
> ?>
> </pre>
> </BODY>
> </HTML>
> 
> 
> Thanks
> 
> 


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to