doushou5761
2014-03-21 10:26
浏览 28
已采纳

获取数组mysql数据库php

I am trying to fetch data from database, but something is not working.

This is my code:

<?php

$koppla = mysql_connect("localhost","admin","","test");



// Check connection


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


    $get = mysql_query($koppla,SELECT * FROM 123);

while ($test = mysql_fetch_array($get))
{
    echo $test['tid'];
}

mysql_close($koppla);
?> `<?php

$koppla = mysql_connect("localhost","admin","","test");



// Check connection


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


    $get = mysql_query($koppla,SELECT * FROM 123);

while ($test = mysql_fetch_array($get))
{
    echo $test['tid'];
}

mysql_close($koppla);
?>

I am getting the following error while trying to fetch an array from a MySQL database. What is wrong?

Parse error: syntax error, unexpected '123' (T_LNUMBER) in C:\wamp\www\test.php on line 16

图片转代码服务由CSDN问答提供 功能建议

我正在尝试从数据库中获取数据,但有些东西无效。 < p>这是我的代码:

 &lt;?php 
 
 $ koppla = mysql_connect(“localhost”,“admin”,“”,“test”);  
 
 
 
 //检查连接
 
 
if(mysqli_connect_errno())
 {
 echo“无法连接到MySQL:”。  mysqli_connect_error(); 
} 
 
 
 $ get = mysql_query($ koppla,SELECT * FROM 123); 
 
而($ test = mysql_fetch_array($ get))
 {
 echo $ test [  'TID']; \ N} 
 
mysql_close($ koppla); 
&GT?;  `&lt;?php 
 
 $ koppla = mysql_connect(“localhost”,“admin”,“”,“test”); 
 
 
 
 //检查连接
 
 
if(mysqli_connect_errno  ())
 {
 echo“无法连接到MySQL:”。  mysqli_connect_error(); 
} 
 
 
 $ get = mysql_query($ koppla,SELECT * FROM 123); 
 
而($ test = mysql_fetch_array($ get))
 {
 echo $ test [  'tid']; 
} 
 
mysql_close($ koppla); 
?&gt; 
   
 
 

我在尝试获取时遇到以下错误 来自MySQL数据库的数组。 有什么问题?

 解析错误:语法错误,第16行的C:\ wamp \ www \ test.php中的意外'123'(T_LNUMBER)
   
 
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题