开发者

PHP-MySQL connection error [closed]

开发者_StackOverflow This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 9 years ago.

I am trying to connect to MySQL via PHP through the following code

<?php

$dbhost = 'localhost';
$dbuser = 'root';
$pass   = 'pass';


 $con = mysql_connect($dbhost,$dbuser,$pass);
 if (!$con)
   {
   die('Could not connect: ' . mysql_error());
   }

 mysql_select_db("test", $con);

 mysql_query("UPDATE cbdb SET fax = '36160'
 WHERE cemail = 'test_cemail@gmail.com' AND cbref = 'test_cbref'");

 mysql_close($con);
 ?>

but an error is showing even though the MySQL connection error is displayed.


are you missing a semi colon after 'pass' ?


you are missing ; after pass and use following syntax

   $db_host=" "; //the host name of the sql server (if you do not know, leave as localhost. usually works)
   $db_name=" ";  //the name of the database
   $db_user=" ";  //the username that is associated with the database
   $db_pass=" "; //the password for the username

   $dbc=mysql_connect($db_host,$db_user,$db_pass) OR DIE (mysql_error());
   $dbs=mysql_select_db($db_name) OR DIE (mysql_error());


You're missing a semicolon on the $pass line.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜