Cannot execute this PHP code...

anuj_web

New Member
Messages
145
Reaction score
0
Points
0
<?php

$dbcnx = @mysql_connect('localhost', 'username', 'password');
if (!$dbcnx) {
echo( '<p>Unable to connect to the ' . 'database server at this time.</p>' );
exit();
}
mysql_select_db('anujweb_donor', $dbcnx);

$sql = 'CREATE TABLE anuj(donorID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,name text)';
if ( @mysql_query($sql) ) {
echo('<p>donor table successfully created!</p>');
} else {
die('<p>Error creating Jokes table: ' .mysql_error() . '</p>');
}
?>



It returns an error no database selected

PS:usename password intentionaly hidden
 

LHVWB

New Member
Messages
1,308
Reaction score
0
Points
0
You shouldn't need to pass the database reference to the mysql_select_db() function, try it without it.
mysql_select_db('anujweb_donor');
 

anuj_web

New Member
Messages
145
Reaction score
0
Points
0
thanks man
it worked
thanks a lot
Edit:
btw how many tables can be made in a single databse ??
 
Last edited:
Top