when select images from a database below error is shown & after i delete record in the database its remain the same number inside (id)
this is the error
Error Number: 1064
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 '16,19,1,2,1,2,1 )' at line 1
select * from images where id in(,16,19,1,2,1,2,1 )
Filename: controllers/Admin.php
Line Number: 1046
and this is select statment :
if (!empty($data->images)) {
$qry = $this->db->query("select * from images where id in($data-
>images )");
$res['results'] = $qry->result();
}
and now my database is empty and this error still remaining ?
just remove the leading comma. like this.
select * from images where id in( 16,19,1,2,1,2,1 )
there is a leading comma in $data->images
$request_id_col and $request_id are strings. However, the request_id_col type in the table is an integer.
$stmt = $db->prepare(' SELECT r.qty, d.name
FROM requested_devices r
JOIN devices d ON r.device_id = d.id
WHERE r.:request_id_col = :request_id
ORDER BY r.id');
$stmt->bindParam(':request_id_col', $request_id_col);
$stmt->bindParam(':request_id', $request_id);
$stmt->execute();
I'm receiving 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 ''sample_id' = '101' ORDER BY r.id' at line 4'
How do I make a query by correctly using bindParam's?
You can't bind table or column names. Only values.
This is query I am using to insert into the table.
I am getting the error like this
$sql = mysql_query("INSERT INTO userinfo(runnername,runnerdob,runnerage,runnergender,runneraddress,runnercity,runnerstate,runnerpincode,runneremail,runnerpassword,runnermobilenumber,e_name,e_relationship,e_address,e_mobilenumber,height,weight,bloodgroup,category,tshirtsize,accountcreationdate,lastlogin,timestamp,registereduser,ipaddress,status)
VALUES('$runnername','$dt',$runnerage,'$runnergender','$runneraddress','$runnercity','$runnerstate','$runnerpincode','$runneremail','$epassword','$runnermobilenumber','$e_name','$e_relationship','$e_address','$e_mobilenumber','$height','$weight','$bloodgroup','$category',$tshirtsize,'$accountdate','Y','$t','Y','$ip',1") or die(mysql_error());
This is generated output
INSERT INTO
userinfo(runnername,runnerdob,runnerage,runnergender,runneraddress,runnercity,runnerstate,runnerpincode,runneremail,runnerpassword,runnermobilenumber,e_name,e_relationship,e_address,e_mobilenumber,height,weight,bloodgroup,category,tshirtsize,accountcreationdate,lastlogin,timestamp,registereduser,ipaddress,status)
VALUES('VIDHYA PRAKASH R','1985-04-08',29,'M','12 DIVINE
RESIDENNCY','coimbatore','TAMILNADU','641035','vidhyaprakash85#gmail.com','FU4A31/GhcmRItAHb97lNtrjRZr+y1yG4arxawG/qEs=','9944524864','rajendran','father','12
DIVINE RESIDENNCY coimbatore TAMILNADU
641035','9894773083','6','6','A1+ve','M',42,'11-07-2014
12:11:02','Y','1405060862','Y','127.0.0.1',1)
but I am getting error as
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 '' at line 1
I am breaking my head for past two hours.
Any one please help me ?
The issue was at the end of the query, writing long insert queries on single line should be avoided and better to write in multiple lines which helps to find the issue almost immediately , or the best is to use prepared statement with PDO or mysqli.
Your query ends as 'Y','$ip',1") which was missing )
Here how the query should be
$sql = mysql_query(
"INSERT INTO userinfo
(
runnername,
runnerdob,
runnerage,
runnergender,
runneraddress,
runnercity,
runnerstate,
runnerpincode,
runneremail,
runnerpassword,
runnermobilenumber,
e_name,
e_relationship,
e_address,
e_mobilenumber,
height,
weight,
bloodgroup,
category,
tshirtsize,
accountcreationdate,
lastlogin,
timestamp,
registereduser,
ipaddress,
status
)
VALUES
(
'$runnername',
'$dt',
$runnerage,
'$runnergender',
'$runneraddress',
'$runnercity',
'$runnerstate',
'$runnerpincode',
'$runneremail',
'$epassword',
'$runnermobilenumber',
'$e_name',
'$e_relationship',
'$e_address',
'$e_mobilenumber',
'$height',
'$weight',
'$bloodgroup',
'$category',
$tshirtsize,
'$accountdate',
'Y',
'$t',
'Y',
'$ip',
1
)"
) or die(mysql_error());
Are you missing a close bracket at the end of your values statement?
Instead of
'$ip',1")
Shouldn't it be
'$ip',1)")
#1064 - 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 '-sporocilo us, uporabnik u WHERE ( 's%' LIKE
u.uuser) AND (s.SID = us.SID) AND (' at line 2
this is the error i get ...
SQL:
SELECT us.ussender, s.ssubject, s.scontent, us.ustimesend, us.usstatus,
FROM sporocilo s, uporabnik-sporocilo us , uporabnik u
WHERE ($user LIKE u.uuser) AND (s.SID = us.SID) AND (us.usreciever LIKE u.uuser),
ORDER BY us.ustimesend ASC;
Database: http://my.jetscreenshot.com/20224/20140415-ls6n-41kb
If your column identifiers are going to contain dashes you must wrap them in ticks. Otherwise MySQL assumes you are performing a subtraction operation.
SELECT us.ussender, s.ssubject, s.scontent, us.ustimesend, us.usstatus,
FROM sporocilo s, `uporabnik-sporocilo` us , uporabnik u
WHERE ($user LIKE u.uuser) AND (s.SID = us.SID) AND (us.usreciever LIKE u.uuser),
ORDER BY us.ustimesend ASC;
The syntax error is missing quotes, here:
WHERE ($user LIKE u.uuser) AND (s.SID = us.SID) AND (us.usreciever LIKE u.uuser),
plus the comma at the end of that line.
There are other problems with your query, but that is beyond the scope of your question.