doubian19900911 2013-04-18 14:44
浏览 40

mysql_fetch_array():“提供的参数不是有效的MYSQL”,带有单个参数[duplicate]

<?php
   $slug = $_GET['artist'];

//Connection details
$con=mysql_connect("localhost","username","password","mydatabase");
// Check connection
if (!$con) {echo "Failed to connect to MySQL"; exit; };


 $result = mysql_query("SELECT * FROM band WHERE slug ='.$slug.'",$con);

$row = mysql_fetch_array($result);

echo $row[1].'<br>';
echo $row[2].'<br>';
echo $row[3].'<br>';
echo $row[4].'<br>';  
   ?>

I cannot for the life of me figure out why there's a problem with the fetching of the array. Just as a FYI, the $_GET request is to grab the artist variable in the url of another webpage, and then what I wished was to pass that variable through MYSQL as a query, to fetch the record that has the same data held in $artist as it is in the slug attribute of band table.

</div>
  • 写回答

2条回答 默认 最新

  • doudizhu2222 2013-04-18 14:48
    关注

    Change your SQL Query to

     $result = mysql_query("SELECT * FROM band WHERE slug='$slug'", $con);
    

    no need for .

    Also please note that mysql_* functions are deprecated as of PHP 5.5.0 and will be removed in the future. http://php.net/manual/en/function.mysql-query.php

    评论

报告相同问题?

悬赏问题

  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思