Hamlets666 Posted January 13, 2007 Share Posted January 13, 2007 [code]$sql2 = "SELECT COUNT(*) FROM load WHERE `fname` = '$gfa' ";$result2 = mysql_query($sql2) or die(mysql_error());$num2 = mysql_result($result2, 0);[/code]Error : [b]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'load WHERE `fname` = 'Muzyka/MP3/Zarubezhnye/N/Nightwish/Nightwish_-_Wish_I_Had_' at line 1[/b]$gfa is /Muzyka/MP3/Zarubezhnye/N/Nightwish/Nightwish_-_Wish_I_Had_an_Angel.mp3What`s wrong ? I do not get a point... :-\ Link to comment https://forums.phpfreaks.com/topic/34014-mysql-error/ Share on other sites More sharing options...
Orio Posted January 13, 2007 Share Posted January 13, 2007 The underscore charater has a special meaning in SQL. Try escaping it:[code]<?php$gfa = str_replace("_", "\_", $gfa);$sql2 = "SELECT COUNT(*) FROM load WHERE `fname` = '$gfa' ";$result2 = mysql_query($sql2) or die(mysql_error());$num2 = mysql_result($result2, 0);?>[/code]Orio. Link to comment https://forums.phpfreaks.com/topic/34014-mysql-error/#findComment-159898 Share on other sites More sharing options...
Hamlets666 Posted January 13, 2007 Author Share Posted January 13, 2007 Now $gfa is Muzyka/MP3/Zarubezhnye/N/Nightwish/Nightwish\_-\_Wish\_I\_Had\_an\_Angel.mp3But still the same : [b]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'load WHERE `fname` = 'Muzyka/MP3/Zarubezhnye/N/Nightwish/Nightwish\_-\_Wish\_I\_' at line 1[/b] Link to comment https://forums.phpfreaks.com/topic/34014-mysql-error/#findComment-159901 Share on other sites More sharing options...
Hamlets666 Posted January 13, 2007 Author Share Posted January 13, 2007 also tried str_replace("_", "666", $gfa);gfa - Muzyka/MP3/Zarubezhnye/N/Nightwish/Nightwish666-666Wish666I666Had666an666Angel.mp3error:[b]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'load WHERE `fname` = 'Muzyka/MP3/Zarubezhnye/N/Nightwish/Nightwish666-666Wish666' at line 1[/b]So "_" isn`t reason of error Link to comment https://forums.phpfreaks.com/topic/34014-mysql-error/#findComment-159905 Share on other sites More sharing options...
wildteen88 Posted January 13, 2007 Share Posted January 13, 2007 add backticks (`) to load as well, eg [tt]`load`[/tt]. I think load is a mysql reserved keyword and MySQL is getting confused. There is nothing wrong with the string in $gfa. It something in the query that is kicking up a fuss. Link to comment https://forums.phpfreaks.com/topic/34014-mysql-error/#findComment-159909 Share on other sites More sharing options...
Hamlets666 Posted January 13, 2007 Author Share Posted January 13, 2007 wildteen88, It`s alive ;) Thanks... Link to comment https://forums.phpfreaks.com/topic/34014-mysql-error/#findComment-159913 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.