I'm new at PHP and MySQL and have a problem

From: Date: Tue, 11 May 2004 19:13:30 +0000
Subject: I'm new at PHP and MySQL and have a problem
Groups: php.db 
Request: Send a blank email to php-db+get-34368@lists.php.net to get a copy of this message
To help me learn using these awesome tools together, I'm creating a sample application for myself - a movie database. In this database (which is named "movies"), I have five tables. One named "moviemain", one named "actors", one named "genre", and then two tables that are designed to link these tables together "moviegenre" and "movieactor". I've created a MySQL query to get all records, and it works great if I use it directly with MySQL, however every time I try it with PHP it gives me a "Resource id #2" message. It seems to have something to do with creating a user connection twice, or something liek that, but I'm not sure. Here's the simple code snippet: <?php $dbcxn = @mysql_connect('localhost','root',''); if (!$dbcxn) { echo('<p>Unable to connect to the database at this time</p>'); exit(); } mysql_select_db('movies',$dbcxn); if (! @mysql_select_db('movies') ) { die('<p>Unable to locate the Movie database within the database server</p>'); } $result = @mysql_query("SELECT * from MovieMain,movieactor,moviegenre,genre,actors where MovieMain.movieid=movieactor.movieid and MovieMain.movieid=moviegenre.movieid and genre.genreid=moviegenre.genreid and actors.actorid=movieactor.actorid"); if (!$result) { die('<p>Error performing query: ' . mysql_error() . '</p>'); } echo $result; ?>

« previous php.db (#34368) next »