Keep getting this line now when i run my sql query:
Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\Users\Murray\Desktop\YouthCafeWork\BookingSystem\bookingrequest.php on line 43
I have tried to change it so that it is using the new syntax but i can not get it to work.
Line 43 (the error line is) is :
$db = mysql_pconnect('localhost', 'root', '');
Thanks for any help in advance :)
As you can see here: http://php.net/manual/en/function.mysql-pconnect.php
mysql_pconnect function is deprecated. Insted of use this function, use: mysqli_connect
For more info, see: http://www.w3schools.com/php/php_ref_mysqli.asp
and:
http://code.tutsplus.com/tutorials/php-database-access-are-you-doing-it-correctly--net-25338
EDIT:
Try this (if you did not set a root password for your mysql server):
$db = new mysqli('localhost', 'root', NULL, 'dabase_name');
Regards PS
support from php for mysql has been deprecated and will be removed very soon so the warning is displayed. use this- object oriented style -
$mysqli = new mysqli("localhost", "my_user", "my_password", "test"); $mysqli->select_db("world");
or Procedural style
$link = mysqli_connect("localhost", "my_user", "my_password", "test");mysqli_select_db($link, "world");
As the documentation of mysql_pconnect() is stating, you should use mysqli_connect()
with p: host prefix:
$db = mysqli_connect('p:localhost', 'root', '');
I suggest you use either mysqli
or PDO
for your database connections.
you should read on PDO and mysqli
PDO connections are done this way
$dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass);
mysqli connection is done this way
$con = mysqli_connect("localhost","my_user","my_password","my_db");