Connect and query mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
slowcoach620
Forum Newbie
Posts: 4
Joined: Tue Aug 10, 2010 5:17 am

Connect and query mysql

Post by slowcoach620 »

I had managed to get an small application working with mysqli_connect() and mysqli_query() but the web host I am using is running PHP 5.2.13.

I seem to be able to connect to the database using mysql_connect() and when I use something like: $result = mysql_query($query); to query the database i get a message saying that no database has been selected. I've tried using $db_selected = mysql_select_db(DB_NAME, $dbc); but I get the message saying that it cannot select the database. Can anyone suggest where I'm going wrong

Kind regards
slowcoach620
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Connect and query mysql

Post by Jonah Bron »

You don't need to put mysql_select_db in a variable. If it can't select the database, that means you don't have permission, or it doesn't exist.
slowcoach620
Forum Newbie
Posts: 4
Joined: Tue Aug 10, 2010 5:17 am

Re: Connect and query mysql

Post by slowcoach620 »

Thanks Jonah I'll give that a try

Regards
John
Post Reply