GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 27-Apr-2007, 12:09
Kacyndra's Avatar
Kacyndra Kacyndra is offline
Member
 
Join Date: May 2005
Location: Maryland
Posts: 230
Kacyndra will become famous soon enough

Can't connect


hi
im VERY new to PHP.

i'm tyring to connect to a db. and it's just not working

please help.

this is what i did to create the database:

PHP Code:

CREATE TABLE Quotes (
  ID int(11) NOT NULL auto_increment,
  Quote char(255) default NULL,
  Name char(255) default NULL,
  IP char(255) default NULL,
  Date char(255) default NULL,
  PRIMARY KEY  (ID)
) TYPE=MyISAM; 




this is what i'm using to connect to it:
PHP Code:

$dbhost         = "myhost";
      $dbusername     = "myusername";
      $dbuserpass     = "mypassword";
      $default_dbname = "quotes";
  
  $connection = mysql_connect($dbhost, $dbusername, $dbuserpass); 
    if (!$connection) 
    { 
        die('Could not connectooo: ' . mysql_error()); 
    } 
      print "++Connected to MySQL<br>";

    print"default: $default_dbname";
    @mysql_select_db($default_dbname) or die( "Unable to select database"); 



and i keep getting this as the output:
++Connected to MySQL
default: quotesUnable to select database

pleeeaase help
__________________
Xrum!
  #2  
Old 28-Apr-2007, 21:59
TurboPT's Avatar
TurboPT TurboPT is offline
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,233
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Can't connect


That looks like you merely created a table named 'Quotes'...

Are you sure that you have a database, named 'quotes', that contains the table [in post1] called 'Quotes' ?

I can only assume this is the case, unless you were in another database when the table was created; otherwise, you would have received: "No database selected"
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
  #3  
Old 01-May-2007, 08:54
karnetics karnetics is offline
New Member
 
Join Date: May 2007
Posts: 10
karnetics is on a distinguished road

Re: Can't connect


Do you already have the database created.. if not... you have to create your db first if it does not exist.
 
 

Recent GIDBlogNot selected for officer school by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to Connect with localhost using FTP vatsaldesai24 .NET Forum 2 02-Nov-2006 05:52
Error when trying to connect AnaXyd MySQL / PHP Forum 0 13-Aug-2005 01:47
clients of certain isp cannot connect to my sites hotwired Web Hosting Forum 3 26-Jul-2005 10:05
Cannot connect to MySQL strahman MySQL / PHP Forum 12 18-Jan-2005 03:38
cannot connect to localhost ? tppradeep18 Apache Web Server Forum 2 25-Feb-2004 04:46

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 04:01.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.