<?php``
if(mysql_connect("localhost","root",""))
echo"connect";
else
echo "not connect";
?>
this is my code but it's not connected . give the error as warning
Warning: mysql_connect(): MySQL server has gone away in C:..\pro1.php on line 2
Warning: mysql_connect(): Error while reading greeting packet. PID=2296 in C:..\pro1.php on line 2
Warning: mysql_connect(): MySQL server has gone away in C:..\pro1.php on line 2 not connect
remove '' after php open tag and try like this
http://php.net/manual/en/mysqli.construct.php
You can try using either
MySQLi
orPDO
and their prepared statement to be more secure.If you intend using just MySQL then use the below code to initialize your Database connection.
For reference see http://php.net/manual/en/function.mysql-connect.php
Alternatively kindly use MySQLi
For reference see http://php.net/manual/en/mysqli.construct.php
If you consider using PDO then try
For reference see http://php.net/manual/en/pdo.connections.php