RE: [PHP] MySQL

From: Date: Mon, 12 Feb 2001 17:21:45 +0000
Subject: RE: [PHP] MySQL
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-39237@lists.php.net to get a copy of this message
For this sort of thing, replacing statements such as : or die("Couldn't execute query."); With : or die(mysql_error()); Would have instantly told you the problem, in nice human readable format. Regards, Philip On Mon, 12 Feb 2001, Brandon Orther wrote: > I fixed it, > > Me so stupid, I had it order by a field that wasn't there. > > -----Original Message----- > From: Brandon Orther [mailto:brandon@webintellects.com] > Sent: Monday, February 12, 2001 9:15 AM > To: PHP User Group > Subject: [PHP] MySQL > > > Hello, > > I am new to MySql and I am trying to make a simple script get info from a > table. Can someone please look at the below code and tell me if they see > what is wrong? The error I get is: Couldn't execute query. > > Code: > > <? > // create connection > $connection = mysql_connect("localhost","*****","*****") > or die("Couldn't make connection."); > > // select database > $db = mysql_select_db("nasty_db", $connection) > or die("Couldn't select database."); > > // create SQL statement > $sql = "SELECT keywords, text, ref_num > FROM tech > ORDER BY last_name ASC"; > > // execute SQL query and get result > $sql_result = mysql_query($sql,$connection) > or die("Couldn't execute query."); > > while ($row = mysql_fetch_array($sql_result)) { > $keywords = $row["keywords"]; > $text = $row["text"]; > $ref_num = $row["ref_num"]; > > echo "Keywords: $keywords<BR>\n"; > echo "Text: $text<BR>\n"; > echo "Refrence Number: $ref_num<BR>\n"; > } > > // free resources and close connection > mysql_free_result($sql_result); > mysql_close($connection); > > ?> > > Thank you, > > -------------------------------------------- > Brandon Orther > WebIntellects Design/Development Manager > brandon@webintellects.com > 800-994-6364 > www.webintellects.com > -------------------------------------------- > > > -- > 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 (#39237) next »