PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 9th, 2012, 10:18 AM
bobskiny bobskiny is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 10 bobskiny User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 24 m 3 sec
Reputation Power: 0
Exclamation 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

Reply With Quote
  #2  
Old October 9th, 2012, 10:47 AM
cafelatte cafelatte is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Mar 2008
Posts: 1,923 cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 5 Days 16 h 21 m 8 sec
Reputation Power: 377
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...

Reply With Quote
  #3  
Old October 9th, 2012, 01:20 PM
bobskiny bobskiny is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 10 bobskiny User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #4  
Old October 9th, 2012, 02:30 PM
cafelatte cafelatte is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Mar 2008
Posts: 1,923 cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 5 Days 16 h 21 m 8 sec
Reputation Power: 377
...just the bit in quotation marks!
...or, more accurately, the output of...

echo $query;

Reply With Quote
  #5  
Old October 9th, 2012, 07:06 PM
bobskiny bobskiny is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 10 bobskiny User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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??

Reply With Quote
  #6  
Old October 9th, 2012, 07:09 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 26,361 r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 5 h 32 m 50 sec
Reputation Power: 4140
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book

Reply With Quote
  #7  
Old October 10th, 2012, 08:28 AM
bobskiny bobskiny is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 10 bobskiny User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #8  
Old October 10th, 2012, 10:30 AM
cafelatte cafelatte is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Mar 2008
Posts: 1,923 cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 5 Days 16 h 21 m 8 sec
Reputation Power: 377
No.

We just want the output of:

echo $query;

Reply With Quote
  #9  
Old October 10th, 2012, 10:38 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 26,361 r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 5 h 32 m 50 sec
Reputation Power: 4140
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

Reply With Quote
  #10  
Old October 10th, 2012, 11:50 AM
bobskiny bobskiny is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 10 bobskiny User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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?

Reply With Quote
  #11  
Old October 10th, 2012, 11:52 AM
cafelatte cafelatte is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Mar 2008
Posts: 1,923 cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 5 Days 16 h 21 m 8 sec
Reputation Power: 377
Yeah, you're STILL NOT SHOWING US THE QUERY - the thing you pasted into phpmyadmin!!!!!!!!!!!!!!!!!!!!!!!!!!

(although this particular problem is a missing comma)

Reply With Quote
  #12  
Old October 10th, 2012, 11:56 AM
bobskiny bobskiny is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 10 bobskiny User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #13  
Old October 10th, 2012, 12:12 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 26,361 r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 5 h 32 m 50 sec
Reputation Power: 4140
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?

Reply With Quote
  #14  
Old October 10th, 2012, 12:45 PM
bobskiny bobskiny is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 10 bobskiny User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #15  
Old October 10th, 2012, 03:15 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 26,361 r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 5 h 32 m 50 sec
Reputation Power: 4140
i will say it one last time...

this is not sql --
Code:
$query = "


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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > SQL error 1064

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap