December 4th, 2013, 08:37 AM
Help with PHP Code
Hi all, I am having a problem with this code to create a table in a selected database. My connectivity is good and I can create the Database no problem, however when I go to run the script I recieve no errors and a blank screen on my local host but when I check to see if the table has been created on phpmyadmin there is no table there also when I check the tables for my database in the cmd line there are no tables also here is my code any help is greatly appreciated.
$con = mysql_connect("localhost","root","");
die("Cannot Connect: " . mysql_error());
$sql = "CREATE TABLE manufacturer (
December 4th, 2013, 08:51 AM
There's a quote instead of the comma -- which you would have found out yourself if you had tested the query or checked the database errors.
What's much worse, though, is that your way of accessing the database is totally outdated. The mysql_* functions are obsolete since almost a decade. People today use PDO or MySQLi:
How to (properly) access a MySQL database with PHP
However, that's something for the PHP forum.
December 4th, 2013, 09:42 AM
You shouldn't be creating tables inside PHP scripts unless this script is meant to be an installer for something. You also REALLY shouldn't be connecting as root from a web script, nor should you be using the deprecated mysql_ functions.
HEY! YOU! Read the New User Guide and Forum Rules
"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin
"The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002
Think we're being rude? Maybe you asked a bad question
or you're a Help Vampire.
Trying to argue intelligently? Please read this.