Jump to content

PHP database not showing in PHPmyadmin


morrism35

Recommended Posts

I have created databases directly  in phpmyadmin control panel and in the command line with no problem. The issue is when I create a database with a php script it is not showing up in phpmyadmin control panel or in the command line. My scripts say that the database was created successfully and I was able to verifiy that it is selected by running a mysql select in my script but again it's not showing up in phpmyadmin control panel or command prompt. The code was taken directly from my textbook with the exception of the hosts, user, and password information in the mysql_connect statement.

 

 

$DBName = "CREATE DATABASE newsletter";
$DBConnect = mysql_connect('127.0.0.1', 'root','Conquest1');
 
if ($DBConnect === FALSE)
echo "<p>Connection error: "
. mysql_error() . "</p>\n";
else{ 
if (mysqli_query($DBConnect, $DBName) === FALSE)
echo "<p>Could not create the \"$DBName\" " .
"database: " . mysql_error($DBConnect) .
"</p>\n";
else
echo "<p>Successfully created the " .
"\"$DBName\" database.</p>\n";
}
if(mysql_select_db($DBName, $DBConnect)===FALSE)
echo"works";
else
echo"doesn't work";
Link to comment
Share on other sites

You should add error checking to this script and you should make a decision on whether to use the mysqli functions or the MySQL functions.  YOu can't mix them together.  Plus - if you took a look at the manual you would see the big highlighted statements telling you NOT to use MySQL stuff.  Despite all this, you also use a query statement as an argument to your select db call.  That's not going to work.

 

Personally I prefer PDO

Edited by ginerjm
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.