morrism35 Posted November 30, 2015 Share Posted November 30, 2015 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"; Quote Link to comment Share on other sites More sharing options...
ginerjm Posted November 30, 2015 Share Posted November 30, 2015 (edited) 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 November 30, 2015 by ginerjm Quote Link to comment Share on other sites More sharing options...
benanamen Posted November 30, 2015 Share Posted November 30, 2015 (edited) * Edited November 30, 2015 by benanamen Quote Link to comment Share on other sites More sharing options...
morrism35 Posted November 30, 2015 Author Share Posted November 30, 2015 Thanks guys that worked. I got all the information from my textbook and it appears my textbook is outdated. My instructor answers his emails maybe 2 wks late so really teaching myself, wasted $250. Ready to transfer from this college. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.