Jump to content

Mysql Error


Hamlets666

Recommended Posts

[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.mp3

What`s wrong ? I do not get a point...  :-\
Link to comment
Share on other sites

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
Share on other sites

Now $gfa is Muzyka/MP3/Zarubezhnye/N/Nightwish/Nightwish\_-\_Wish\_I\_Had\_an\_Angel.mp3

But 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
Share on other sites

also tried str_replace("_", "666", $gfa);
gfa - Muzyka/MP3/Zarubezhnye/N/Nightwish/Nightwish666-666Wish666I666Had666an666Angel.mp3
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/Nightwish666-666Wish666' at line 1[/b]

So "_" isn`t reason of error
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.