php - mysql_fetch_array(): "supplied argument is not a valid MYSQL", with single argument -


<?php    $slug = $_get['artist'];  //connection details $con=mysql_connect("localhost","username","password","mydatabase"); // check connection if (!$con) {echo "failed connect mysql"; exit; };    $result = mysql_query("select * band 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 life of me figure out why there's problem fetching of array. fyi, $_get request grab artist variable in url of webpage, , wished pass variable through mysql query, fetch record has same data held in $artist in slug attribute of band table.

change sql query to

 $result = mysql_query("select * band slug='$slug'", $con); 

no need .

also please note mysql_* functions deprecated of php 5.5.0 , removed in future. http://php.net/manual/en/function.mysql-query.php


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -