Reputation: 6622
I trying to connect php to mysql. I am not using any tool like (xampp or wamp). I have separately installed apache/php/mysql. Now I am trying to connect to my sql using following code but nothing happening. it just prints 'started'.
<?php
echo 'started'."<br/>";
mysql_connect("localhost", "root", "root");
echo 'mysql connected'."<br/>";
mysql_select_db("test");
echo 'db connected'."<br/>";
mysql_query("CREATE TABLE MyTable (
id INT AUTO_INCREMENT,
FirstName CHAR,
LastName CHAR,
Phone INT,
BirthDate DATE
PRIMARY KEY(id)
)");
mysql_close ();
?>
Upvotes: 0
Views: 106
Reputation: 908
turn ON your error reporting
check this line: mysql_connect("localhost", "root", "root");
if it prints just "started" it means somewhere you have a "fatal error". mysql_connect won`t stop the script execution if you just entered the wrong details (username/password/server address).
some of the errors may happen if you haven't enabled the php_mysql extension in your php configuration file.
Upvotes: 1