RE: [PHP] MySQL COUNT Won't Work

From: Date: Fri, 16 Feb 2001 17:39:11 +0000
Subject: RE: [PHP] MySQL COUNT Won't Work
Groups: php.general 
Request: Send a blank email to php-general+get-40185@lists.php.net to get a copy of this message
Nope, with php the second argument of mysql_query is indeed the connection identifier. What happens when you run the query via the mysql client? -jm -----Original Message----- From: Jon Haworth [mailto:JHaworth@witanjardine.co.uk] Sent: Friday, February 16, 2001 9:32 AM To: 'jeff@webdesigns1.com'; 'php-general@lists.php.net' Subject: RE: [PHP] MySQL COUNT Won't Work Shouldn't that be $result = mysql_query($sql,$db) or die("Couldn't execute query."); So you're querying the database, and not the connection? HTH Jon -----Original Message----- From: Jeff Oien [mailto:jeff@webdesigns1.com] Sent: 16 February 2001 17:27 To: PHP Subject: [PHP] MySQL COUNT Won't Work I'm totally stuck on this code. I get the error "Couldn't execute query." so I know where it's failing but can't figure out what's wrong. I have a database with 'title' as one of the fields. Based on code in PHP Fast and Easy. Jeff Oien <?php $db_name = "Music"; $table_name = "music"; $connection = mysql_connect("localhost", "xxxx", "xxxx") or die("Couldn't connect."); $db = mysql_select_db($db_name, $connection) or die("Couldn't select database."); $sql = "SELECT COUNT (title) FROM music"; $result = mysql_query($sql,$connection) or die("Couldn't execute query."); //<<error from here $count = mysql_result($result,0,"count(title)"); echo "$count"; ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#40185) next »