解析错误:语法错误,意外的'2342364'(T_LNUMBER),期望变量(T_VARIABLE)或第10行的www / hariommahawar.tk / index.php中的'$'

时间:2017-04-19 05:07:51

标签: php

  

解析错误:语法错误,意外的'2342364'(T_LNUMBER),期待   在www / hariommahawar.tk / index.php上的变量(T_VARIABLE)或'$'在线   10

数据库连接问题plz找到错误

<?PHP
error_reporting(E_ALL ^ E_DEPRECATED);


$server = "localhost";//localhost
$user = "hostingc_shaadi2";
$password = "";
$dbName = "2342364_hmj";

$conn = mysql_connect($server,$user,$password,$2342364_hmj )
    or die("There was a problem connecting to MySQL. Please try again later.");

?>

2 个答案:

答案 0 :(得分:1)

使用以下给出的方法:

 MobileAds.initialize(getActivity(), "ca-app-pub-3490247194261556/7252350096");

    AdView mAdView = (AdView) rootView .findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);

重要更新

mysql是一种过时的方法,你应该考虑切换到mysqli或PDO。

在此处阅读有关mysqli的更多信息:https://www.w3schools.com/php/php_ref_mysqli.asp

以及有关PDO的更多内容:https://www.w3schools.com/php/php_mysql_prepared_statements.asp

为什么不在这里使用mysql_ *:Why shouldn't I use mysql_* functions in PHP?

答案 1 :(得分:0)

您传递db name错误。因为你使用的是mysql而不是mysqli。 使用它。

//make connection
$conn = mysql_connect($server,$user,$passwor);
if (!$conn) {  
   die('Not connected : ' . mysql_error());  
 }  
//select database
$db_selected = mysql_select_db($dbname, $conn);
if (!$db_selected) {
    die ('blog not selected : ' . mysql_error());
}

最佳解决方案是使用mysqli,因为它是mysql的增强版。

 $conn = mysqli_connect($server,$user,$passwor,$dbname);

 // Check connection
 if (mysqli_connect_errno())
 {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
 }