SELECT * FROM TABLE
Posted: Sat Jun 27, 2009 4:37 am
I'm having a difficult time selecting data from a table that I have inserted.
The first thing I did was inserted the following string into a table:
Time Marches On.mp3 <-this is the string.
I used mysql_real_escape_string($string) to insert the data.
Now want to select the string I just inserted. So I do the following:
$file = 'Time Marches On.mp3';
$query = mysql_query("SELECT * FROM audio WHERE name = $file");
while($row = mysql_fetch_array($query)){
echo $row['name']."</br>";
}
I get the following error:
PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
I look through phpMyAdmin and see the string is in the table and the variable $string is spelled correctly but somewhere between php & mysql something is different in the string.
Any ideas why this might be happening? Any help would be appreciated.
The first thing I did was inserted the following string into a table:
Time Marches On.mp3 <-this is the string.
I used mysql_real_escape_string($string) to insert the data.
Now want to select the string I just inserted. So I do the following:
$file = 'Time Marches On.mp3';
$query = mysql_query("SELECT * FROM audio WHERE name = $file");
while($row = mysql_fetch_array($query)){
echo $row['name']."</br>";
}
I get the following error:
PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
I look through phpMyAdmin and see the string is in the table and the variable $string is spelled correctly but somewhere between php & mysql something is different in the string.
Any ideas why this might be happening? Any help would be appreciated.