1064 - You have an error in your SQL syntax; [closed] - php

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

Related

Error Get Data SQL from controller PHP CI [closed]

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.

MySQL #1064 error for location finder [closed]

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'm trying to find the 10 entries that are closest to the user with the following search:
$data_query = mysqli_query($db, "SELECT *
111.045 * DEGREES(ACOS(COS(RADIANS(latpoint))
* COS(RADIANS(latitude))
* COS(RADIANS(longpoint) - RADIANS(longitude))
+ SIN(RADIANS(latpoint))
* SIN(RADIANS(latitude)))) AS distance_in_km
FROM merchants
JOIN (
SELECT 33.889676 AS latpoint, 151.193024 AS longpoint
) AS p ON 1=1
ORDER BY distance_in_km
LIMIT 15");
However I'm getting the following 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 '111.045 * DEGREES(ACOS(COS(RADIANS(latpoint))
* COS(RADIANS(la' at line 2
I tried changing SELECT * to SELECT latitude, longitude (with `` but Stack Overflow keeps messing up syntax) but it's not doing much.
I'm new to PHP and MySQL so I'm feeling pretty out of depth as to what could be going wrong here.
Cheers :)
If you want also select everything, then add comma after first *: SELECT *, 111.045 ...
If not, then remove first *

sql & pdo syntax error? [closed]

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 6 years ago.
Improve this question
i have a pdo statement for select all rows for row count.... i keep getting this error "Call to member function execute() on Boolean" ...i have tripple checked my statement and database table but cant find anything wrong
$stmt = $connection->prepare("SELECT * FROM users_profile WHERE email=:email");
var_dump($connection->error);
$stmt->execute(":email",$email);
$count = $stmt->rowCount();
Var dump error says there is a syntax error here " :email" ..but i cant seem to see it...and its doing this through out my PDO code
The execute function of PDO expect to get array of parameters
public bool PDOStatement::execute ([ array $input_parameters ] )
This is how you should use it in your code:
$stmt->execute( [":email" => $email] );

Mysql error 1064.PHP when select data with forward slashes [closed]

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

SQL WHERE syntax error [closed]

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},
^

Categories