mysql-error-1064

PHP cries Syntax Error on simple SQL WHERE clause.

mysql_query('SELECT ID FROM documents WHERE (Key="' .$theKey. '" AND Value="' .$theValue. '")'); Isn’t this right? Also tried with a semicolon at the end of the string, but no luck. Driving me crazy, PHP keeps spitting out: You have an error in your SQL syntax; check the manual that c...

Syntax error in automatically formed SQL query

I am trying to generate a query for use with a smart search field, ala google suggest. I can not form the query directly, although I can see what query was made via the logs. I have posted the query that gets sent, which has a syntax error but I am unsure why. SELECT DISTINCT IF(guests.passport != '', Concat(guests.passport, ...

is there an error on this sql request?

$sql=mysql_query("INSERT INTO admin_cont (contact_idemail , contact_timestamp , contact_objet , contact_message) VALUES ('".$_COOKIE['zzzzz']."', '$timestamp', '$objet', '$message' ") or die(mysql_error()); i keep getting the error: You have an error in your SQL syntax; check th...

Joining Query problem

I want to join 2 tabls with id. I wrote following query but i am getting an error. I want to select all columns simultaneously in mysql. select t1.* t2.* table1t1 JOIN table2t2 ON t1.id = t2.postads_id where ads_id=1277719543 AND email='[email protected]'; ERROR: #1064 - You have an error in your SQL syntax; che...

adding a calculated/virtual column to an existing query

My query returns a sales column total for each month and a purchases total for each month, for certain categories. SELECT theMonth, sum(Sales) as sumSales, sum(Saleswotax) as sumSaleswotax, sum(Purchases) as sumPurchases, sum(Purchaseswotax) as sumPurchaseswotax FROM ( SELECT date_format(saledate, '%Y-%...

MySQL query error.

Can someone help me correct the following error I keep getting when trying to run my MySQL query. Here is my 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 'WHERE user_id = '3' AND id = '3' AND friendship_status = '0'' at line 2 Here is my m...

Error Code 1064 MySQL

I need to know what i am doing wrong right now in this. Can someone tell me how to fix it? mysql>host/"localhost"; mysql>port=3306; database=ml username=**** password=******** clientamount=30; I need to know how to fix the first line can anybody tell me? ...

MySQL INSERT Query

I have problem with my MySQL query: include '../inc/mysql_config.php'; $sql="INSERT INTO ordrar (id, order, namn, adress, postnummer, postort, email, status) VALUES (NULL, '$order','$namn','$adress','$postnummer', '$postort', '$email', '$email', '$status')"; mysql_query($sql); if (!mysql_query($sql)) { die('Erro...

Using Cursor in a Loop of a stored procedure

So as to use cursors dynamically using MySQL is it possible to declare a cursor in a loop of a stored procedure? I've tried and got an error: increment: LOOP DECLARE cur1 CURSOR FOR SELECT person_id, publication_id FROM p_publication WHERE person_id = new_count; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; OPEN cur1; REPEAT ...

What is wrong with this mysql create table query?

I have a database in my production server and it works fine... What i did is took a dump of that DB and executed in my local system.. All the other tables are created except one table... So i manually inserted it, CREATE TABLE `contact` ( `contactId` int(11) NOT NULL AUTO_INCREMENT, `cRefId` int(20) DEFAULT '0', `contactFirstName`...

MySQL "an error in your SQL syntax"

Hi! I'm trying to change a database entry with PHP but is stuck with this error message: 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 'Bjelkholm Lövgren AND adress = Brinellgatan 14 AND postnummer = 57135 ' at line 1 Code: ...

mysql query error in php

Select COUNT(*) as num t1.id,t1.ads_city,t1.ads_title,t1.ads_description,t1.ads_location,t2.ads_date,t2.ads_image,t2.ads_id,t2.ads_time,t2.postads_id ,t2.ads_url FROM postads t1 JOIN nextpostads t2 ON t1.id = t2.postads_id WHERE t2.ads_activate="Yes" AND t1.ads_type="offerring" AND t1.ads_category="Learning & Education" ...

sql syntax, if exist

Hi, why i get 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 'IF EXISTS(SELECT id FROM mytable WHERE id = '1')' at line 1 query: IF EXISTS(SELECT id FROM mytable WHERE id = '1') Thanks ...

What wrong with this query?

INSERT INTO product_search_table (id, score) VALUES ( SELECT product_id, 50 FROM cart_product WHERE product_id = 555 ) Is giving me an error. What am I doing wrong? 555 is going to be replaced with a variable. ...

MySQL Subquery is failing on MySQL 4.0 with invalid syntax error

I'm running a pretty basic subquery on MySQL 4.0.30. My goal is to get the user permissions from the mysql.user table for any user with grants on a specific database, as noted in the mysql.db table. The query looks like this: mysql> select * from mysql.user where User IN (select User from mysql.db where Db='db_name')\G As you can...

MySQL syntax problem in "SELECT * FROM INTO FILE"

I'm trying to move tables between two databases and I'm using this command that is given by MySQL : SELECT * INTO OUTFILE '/tmp/result.txt' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM test_table; As it is written in the MySQL Dev Manual. I'm using MySQL 5.1. Error : Error Code:...

how to use quote in mysql syntax ?

I try this in PHPMyadmin: Update wp_1_posts SET post_content='<strong>Hello </strong> <a href="http://stackoverflow.com"&gt;stackoverflow&lt;/a&gt; you think you're good at sql.\n then answer\n' WHERE post_ti<tle = 'stupid example' and it says bad syntax. Why ? ...

mysql syntax error inserting decimal, timestamp with php

Im getting the 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 '10', '16:39:02', '292.35')' at line 1 this is the query im running in php: mysql_query("INSERT INTO `copper` (`month`, `time`, `price`) VALUES ...

Subquery error in MySQL with max()

I'm trying a subquery in MySQL using max(), and I keep running into an error. The gist of the query is below (though I've changed the field names). select table1.field1, table1.field2, table2.field3, table2.field4, table3.field5, (select max(age) from age_table where age_table.person = table2.person) from...

truncate procedure for all records

HI, the procedure is giving error as a: Script line: 4 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 'cmd; EXECUTE stmt; DROP PREPARE stmt; -- End of loop U' at line 25 pls correct me any one,thanking u in advqance... DELIMITER $...