Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
When I run:
$query = "UPDATE subjects SET
menu_name = '{$menu_name}',
position = {$position},
visible = {$visible},
WHERE ID = {$ID}";
$result = mysql_query($query, $connection);
I get back:
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 'WHERE ID = 1' at line 5
Remove this comma before the WHERE clause. Since there are no more values to update, the comma is not needed and hence causes a syntax error.
visible = {$visible},
^
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
i have some trouble to find the correct syntax to update a token in a database.
I'm having some trouble trying to fine the correct syntax in order to write a query that updates a token in the database.
This is what my current attempt looks like:
$sql = "UPDATE ComptePro
SET `Token` = :Token,
WHERE `Index` = :Index";
echo $Indexuser;
echo " ";
echo $token;
$req = $bdd->prepare($sql);
$req->bindParam(':Token', $token, PDO::PARAM_STR);
$req->bindParam(':Index', $Indexuser, PDO::PARAM_INT);
$req->execute();
Though this is the error I am getting:
$sql = "UPDATE ComptePro
SET `Token` = :Token, <----problem is here
WHERE `Index` = :Index";
If you remove the comma, that code should run ok
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
This is my code below to find numbers starting 34 and 54 but i am getting the error
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 'WHERE address LIKE '34%' at line 1, Time: 0.123000s
SELECT *
FROM db.table
WHERE uid = 'test'
AND WHERE destination_addr LIKE '34%'
AND WHERE address LIKE '54%';
What could i be doing wrong ?
Too many WHERE clause usage. Use only one WHERE like below-
SELECT *
FROM db.table
WHERE uid = 'test'
AND destination_addr LIKE '34%'
AND address LIKE '54%';
See Syntax: https://dev.mysql.com/doc/refman/8.0/en/select.html
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
i getting data sql from controller and here is my code
$qr = $this->db->query("select journalDetail.JOURNAL_ID, JOURNAL_TYPE_CODE, JOURNAL_NUMBER, JOURNAL_MEMO, COA_CODE, JOURNAL_DETAIL_DESC, CURRECY_ID, JOURNAL_DETAIL_ORIG, JOURNAL_DETAIL_SUM, JOURNAL_DETAIL_TYPE, date_format(JOURNAL_DATE,'%d %M %Y') AS DATE, from t_journal_detail journalDetail left join t_journal journal on journalDetail.journal_id=journal.journal_id where JOURNAL_DETAIL_ID = '".$journalDetailId."'");
$gen = $qr->result();
But my code was 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 'from t_journal where JOURNAL_ID = '83'' at line 1
select JOURNAL_NUMBER, JOURNAL_MEMO, date_format(JOURNAL_DATE,'%d %M %Y') AS DATE, from t_journal where JOURNAL_ID = '83'
Please i need help i don't know to fix this syntax
You have a comma (,) before the from keyword: and after 'AS DATE'-
date_format(JOURNAL_DATE,'%d %M %Y') AS DATE, from t_journal_detail
Remove the comma and I think your problem will be solved.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I'm having a strange error with my PHP code. it says there is a unexpected T_CONSTANT_ENCAPSED_STRING error, but I simply can't see it.
$dateResult = mysqli_query($connection, 'select county, cuisine,
count(*) from inspection, restaurant where inspection.rid =
restaurant.rid and inspection.passfail = ''PASS'' and idate like '$date%'
group by county, cuisine');
I'm assuming its an issue with either my like pattern '$date%' or with 'PASS'.
Thank you!
Try this your are conflicting ' and "
$dateResult = mysqli_query($connection, "select county, cuisine,
count(*) from inspection, restaurant where inspection.rid =
restaurant.rid and inspection.passfail = 'PASS' and idate like '$date%'
group by county, cuisine");
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I try to execute this query with PHP. but mysql server is giving to error like this.
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 'index='CEA/EO/MA/0001'' at line 1. What is the reason for that?
My PHP code part is
$index = ($_POST['index']);
$sql = "SELECT * FROM results WHERE index='CEA/EO/MA/0001'";
$query = mysql_query($sql) or die(mysql_error());
index is a reserved keyword in MySQL. If you're going to name a column index you wrap it in backticks:
$sql = "SELECT * FROM results WHERE `index`='CEA/EO/MA/0001'";
Refer to the following page for the full list of MySQL reserved words:
http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html