KingPin's Forum
 
K.P.s.N. Register vbBux / KPs Mall Bugs Blogs FAQ Search Today's Posts Mark Forums Read Donate
Go Back   KingPin's Forum > KP's Network Forum > RSS News
Reload this Page Selecting a MySQL database with PHP?
 


RSS News This is a discussion on Selecting a MySQL database with PHP? in the RSS News;
Description: This is my first website using MySQL and PHP and I'm having some troubles. So...I'm connected to the MySQL server ...

Reply
 
LinkBack Thread Tools
Selecting a MySQL database with PHP?
(#1 (permalink))
Old
Laura is Offline
Private
Points: 191, Level: 2 Points: 191, Level: 2 Points: 191, Level: 2
Activity: 0% Activity: 0% Activity: 0%
Laura is an unknown quantity at this point
 
 
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: Dec 2007
Selecting a MySQL database with PHP? - December 28th, 2007

This is my first website using MySQL and PHP and I'm having some troubles. So...I'm connected to the MySQL server using mysql_connect - no problem there. But when trying to select a database, I get the error 'unknown database'. This is what I wrote to select:
if (!@mysql_select_db('my_database')){
die ('<p>Could not select the database because: <b>'. mysql_error(). '</b></p>');}

To make my database I used MySQL Server 2005 Express. And I also have XAMPP -- I chose it because it was the only Apache that would run for me. Anyone has any idea what I might be doing wrong?
As far as I know the database is created I created it in Mysql server management studio. I don't know should I do something more with it, it's not enough to just create it there?

 
Reply With Quote
Revenue Shared Ads
(#2 (permalink))
Old
Master ß is Offline
Private
Points: 157, Level: 2 Points: 157, Level: 2 Points: 157, Level: 2
Activity: 0% Activity: 0% Activity: 0%
Master ß is an unknown quantity at this point
 
 
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: Dec 2007
December 28th, 2007

Did you actually create the database you're trying to connect to? If the database doesn't yet exist you won't be able to connect to it (I ran into this myself the other day when I was setting up phpBB and MySQL, I forgot to create the database <g>).

 
Reply With Quote
(#3 (permalink))
Old
byteofk is Offline
Private
Points: 213, Level: 2 Points: 213, Level: 2 Points: 213, Level: 2
Activity: 0% Activity: 0% Activity: 0%
byteofk is an unknown quantity at this point
 
 
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: Dec 2007
December 28th, 2007

Check this page:

http://us3.php.net/function.mysql-connect

This is what my hosting provider gives me as instructions on connecting:

$db = mysql_connect ("localhost", "username", "******");
mysql_select_db ("dbname", $db);

Looks like you're missing some info as to which db to connect to in which connection.

 
Reply With Quote
(#4 (permalink))
Old
byteofk is Offline
Private
Points: 213, Level: 2 Points: 213, Level: 2 Points: 213, Level: 2
Activity: 0% Activity: 0% Activity: 0%
byteofk is an unknown quantity at this point
 
 
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: Dec 2007
December 28th, 2007

Check this page:

http://us3.php.net/function.mysql-connect

This is what my hosting provider gives me as instructions on connecting:

$db = mysql_connect ("localhost", "username", "******");
mysql_select_db ("dbname", $db);

Looks like you're missing some info as to which db to connect to in which connection.
 
Reply With Quote
(#5 (permalink))
Old
byteofk is Offline
Private
Points: 213, Level: 2 Points: 213, Level: 2 Points: 213, Level: 2
Activity: 0% Activity: 0% Activity: 0%
byteofk is an unknown quantity at this point
 
 
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: Dec 2007
December 28th, 2007

Check this page:

http://us3.php.net/function.mysql-connect

This is what my hosting provider gives me as instructions on connecting:

$db = mysql_connect ("localhost", "username", "******");
mysql_select_db ("dbname", $db);

Looks like you're missing some info as to which db to connect to in which connection.
 
Reply With Quote
Revenue Shared Ads
Reply

Bookmarks

Tags
database, mysql, php, selecting

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Rupees Per Thread View: 1.00
Rupees Per Thread: 15.00
Rupees Per Post: 5.00
Forum Jump



These are the 100 most searched terms
Search Cloud
_backup.rc antrix wow antrix wow server autocad 2007 keygen best google gadgets best wow character bt map devil may cry 4 crack enchanting leveling erika bella fuckteam fuckteam 5 georgina lempin gigistar gigistar topless kpsden kpsforum leatherworking guide leveling enchanting mangos custom vendors mangos item id mangos linux mangos server mangos spell id mangos wotlk mature creampie milena velba no rest for the ass object id wow phoenix marie this is sparta vipersdenforums voyage century bot windows activation workaround windows xp lite wotlk alpha private server wotlk private server wotlk server wotlk wiki wow leatherworking guide wow mount locations wow object id wow object id list wow object id's wow object ids wow objects id www.adobeflashplayer www.adobeflashplayer.com www.kpsforum.com xbox 360 mmorpg ... powered by Simple Search Cloud
Powered by vBulletin® Version 3.8.0 Beta 3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
Copyright 2004-2009 KPsN


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82