The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
SQL error 1064
Discuss SQL error 1064 in the PHP Development forum on Dev Shed. SQL error 1064 PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

October 9th, 2012, 10:18 AM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 10
Time spent in forums: 1 h 24 m 3 sec
Reputation Power: 0
|
|
SQL error 1064
I have a piece of code which is written to call record from a MySQL database. everything is right and the connection goes through but when i put this statment into PHP myadmin in the SQL part of it;
The statement is;
PHP Code:
$query = "SELECT * MATCH (firstname, lastname) AGAINST ('".$trimm."') AS score FROM Trophies WHERE MATCH (firstname, lastname) AGAINST ('+".$trimm."') ORDER BY score DESC";
but the error i am getting is;
error 1064 - #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 '$query = "SELECT * MATCH (firstname, lastname) AGAINST ('".$trimm."') AS score ' at line 1
I have another line similar which recieves the same error
What have i tried;
- I tried putting single quotes instead of double quotes
- I tried putting no quotes
|

October 9th, 2012, 10:47 AM
|
|
|
|
Don't put the WHOLE line into phpmyadmin, just the bit in quotation marks!
It still won't be right, but you'll be one step nearer...
|

October 9th, 2012, 01:20 PM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 10
Time spent in forums: 1 h 24 m 3 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by cafelatte Don't put the WHOLE line into phpmyadmin, just the bit in quotation marks!
It still won't be right, but you'll be one step nearer... |
cheers
|

October 9th, 2012, 02:30 PM
|
|
|
|
...just the bit in quotation marks!
...or, more accurately, the output of...
echo $query;
|

October 9th, 2012, 07:06 PM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 10
Time spent in forums: 1 h 24 m 3 sec
Reputation Power: 0
|
|
|
thanks but its giving me the same error message,do you how to fix it by any chance??
|

October 9th, 2012, 07:09 PM
|
 |
SQL Consultant
|
|
Join Date: Feb 2003
Location: Toronto Canada
|
|
Quote: | Originally Posted by bobskiny thanks but its giving me the same error message,do you how to fix it by any chance?? | can you please show the exact code you passed to mysql
|

October 10th, 2012, 08:28 AM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 10
Time spent in forums: 1 h 24 m 3 sec
Reputation Power: 0
|
|
|
how do you mean, the part i wrote in my orginal entry was the part i copied into the sql part of phpmyadmin and then i got that 1064 error.
but if you are asking me for the rest of my code then i can give you that aswell??
Thank you for helping me
|

October 10th, 2012, 10:30 AM
|
|
|
|
No.
We just want the output of:
echo $query;
|

October 10th, 2012, 10:38 AM
|
 |
SQL Consultant
|
|
Join Date: Feb 2003
Location: Toronto Canada
|
|
Quote: | Originally Posted by bobskiny the part i wrote in my orginal entry was the part i copied into the sql part of phpmyadmin | we've been trying to tell you that mysql cannot handle php code
if you submitted this to phpmyadmin --
Code:
$query = "SELECT * MATCH (firstname, lastname) AGAINST ('".$trimm."') AS score FROM Trophies WHERE MATCH (firstname, lastname) AGAINST ('+".$trimm."') ORDER BY score DESC";
then mysql is gonna barf immediately on that red part
mysql can only handle pure sql, which is the SELECT statement after all php variables in it have been substituted
which is why we keep asking you to run your php code and put in the echo statement so that you can see the $query sql string
then that $query sql string is what you copy/paste into phpmyadmin
|

October 10th, 2012, 11:50 AM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 10
Time spent in forums: 1 h 24 m 3 sec
Reputation Power: 0
|
|
|
This helps, thanks i can see where the error is being caused better.
the error i am getting now is the same but shows a more specific part of the code;
#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 'MATCH (firstname, lastname) AGAINST ('".$trimm."') AS score FROM Trophies WHERE ' at line 1
does anyone know the problems now please?
|

October 10th, 2012, 11:52 AM
|
|
|
|
Yeah, you're STILL NOT SHOWING US THE QUERY - the thing you pasted into phpmyadmin!!!!!!!!!!!!!!!!!!!!!!!!!!
(although this particular problem is a missing comma)
|

October 10th, 2012, 11:56 AM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 10
Time spent in forums: 1 h 24 m 3 sec
Reputation Power: 0
|
|
sorry dont go mad at me please but i dont knwo what you mean, see i am new to this;
this is what i think you mean but i dont know;
PHP Code:
[PHPNET]foreach ($trimmed_array as $trimm){
$query = "SELECT * MATCH (firstname, lastname) AGAINST ('".$trimm."') AS score FROM Trophies WHERE MATCH (firstname, lastname) AGAINST ('+".$trimm."') ORDER BY score DESC";
$numresults=mysql_query ($query);
$row_num_links_main =mysql_num_rows ($numresults); [/PHPNET]
hope this is what you want this is the whole block thankyou for participating with me
|

October 10th, 2012, 12:12 PM
|
 |
SQL Consultant
|
|
Join Date: Feb 2003
Location: Toronto Canada
|
|
|
could you do me a favour please
describe, in your own words, the difference between running a query from inside your php code, versus running a query through the sql window of phpmyadmin
what is the key difference between those two methods?
|

October 10th, 2012, 12:45 PM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 10
Time spent in forums: 1 h 24 m 3 sec
Reputation Power: 0
|
|
|
well i had this code which had was not executing properly and kept giving me an error saying resource needed, boolean given whihc was on line 52 whihc was the last line in my previous entry;
$row_num_links_main =mysql_num_rows ($numresults)
and i saw a youtube video which said the problem was not actualy with this line and was infact with the line i put before;
$query = "SELECT * , MATCH (firstname, lastname) AGAINST ('".$trimm."') AS score FROM Trophies WHERE MATCH (firstname, lastname) AGAINST ('+".$trimm."') ORDER BY score DESC";
and he said to put this into phpmyadmin on the sql tab and then it will show you what the mistake is so i did this and still couldnt figure out what the mistake was and that is why i asked on this forum
the only difference i see between the two methods is that the phpmyadmin gives you more of a clue as to where the mistake is, but i just really need some help because i dont really have clue about what i am doing. i dont have the time to learn the language properly right now as i did HTML and CSS
|

October 10th, 2012, 03:15 PM
|
 |
SQL Consultant
|
|
Join Date: Feb 2003
Location: Toronto Canada
|
|
i will say it one last time...
this is not sql --
that's php code and mysql will barf on it
whatever you paste into the phpmyadmin sql window has to be sql only -- no php code
also, we've asked you a couple of times to put an echo statement into your php code so that you can see for yourself the query string that your php code is building
when you echo out that php string, it will start with the mysql keyword SELECT and that's what you would then copy/paste into phpmyadmin's sql window to test
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|