0
$sql="SELECT * FROM 'image_upload' where uid='$uid' ";

I have written this query and it is showing me error :-

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 ''image_upload' where uid=''' at line 1

Can you please rectify it..

Shamim Hafiz - MSFT
  • 21,454
  • 43
  • 116
  • 176
user799100
  • 133
  • 2
  • 16

8 Answers8

9

This will work:

$sql = "SELECT * FROM `image_upload` where uid='$uid' ";
Manish Das
  • 3,785
  • 2
  • 21
  • 34
  • yes, my uid is not char or varchar, it is bigint and when i put the query as suggested by you, it shows me uid 0 in my database – user799100 Jun 16 '11 at 07:24
  • 2
    are you sure that $uid store the number you want??? or may be the previous insertions into uid column have size less than the length of your number. – Manish Das Jun 16 '11 at 07:54
4

Use backticks for table names:

SELECT * FROM `image_upload` ...
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
1

You should be using backticks (`) rather than single quotes ('). In fact, you shouldn't be using either in this case since it's not required:

$sql = "SELECT * FROM image_upload where uid='$uid'";

The backticks are only required if your table name has funny characters in it that would otherwise annoy the SQL parser (like a space for example).

And make sure that your uid column is a textual one (like char or varchar) - otherwise you should not be surrounding $uid with the single quotes.

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
0

$sql="SELECT * FROM image_upload where uid='$uid' ";

gmhk
  • 15,598
  • 27
  • 89
  • 112
0

Can you remove the single quotes, and try again?

SELECT * FROM image_upload where uid='$uid'
Liangliang Zheng
  • 1,763
  • 11
  • 16
0

try this:

$sql="SELECT * FROM image_upload where uid='".$uid."'";
Sujit Agarwal
  • 12,348
  • 11
  • 48
  • 79
0
$sql="SELECT * FROM `image_upload` where uid='$uid' ";

You've been rectified ;)

You need to protect against SQL injections. Please see this thread.

Community
  • 1
  • 1
Markus Hedlund
  • 23,374
  • 22
  • 80
  • 109
-1

Remove single quotes in image_upload Before Query echo $uid; then u ll know the answer

K6t
  • 1,821
  • 1
  • 13
  • 21