MANIKANT PATIDAR
MANIKANT PATIDAR

Reputation: 31

What is mistake in above sql?

I am unable to run this sql. This is not give me data.

$sql = "Select * from user where user_id=1'";

mysql_query($sql);

Upvotes: 2

Views: 100

Answers (5)

Ankit Purwar
Ankit Purwar

Reputation: 522

Use this:

$sql = "Select * from user where user_id=1";

mysql_query($sql);

single quote after 1 is unnecessary.(also, the Numeric Data Types is not placed inside quotes for example.. '1' or "1" is incorrect and will throw an error,just in case this is what you were trying to do.)

Upvotes: 1

Pratik
Pratik

Reputation: 139

use this code

$sql = "Select * from user where user_id=1";

mysql_query($sql);

Upvotes: 1

Sagar Mal Shankhala
Sagar Mal Shankhala

Reputation: 313

Remove single quote (')

use this code:

$sql = "Select * from user where user_id=1";

mysql_query($sql);

Upvotes: 1

Jagdish Thakre
Jagdish Thakre

Reputation: 158

remove ' after 1, this is silly mistake.

$sql = "Select * from user where user_id=1";

mysql_query($sql);

Upvotes: 9

Gynteniuxas
Gynteniuxas

Reputation: 7103

There is an unncessary ' after 1. But also:

http://php.net/manual/en/function.mysql-query.php

mysql_query() - this extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0.

Better solution: MySQLi query

Upvotes: 1

Related Questions