Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

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 January 9th, 2004, 01:04 PM
Silver Machine Silver Machine is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: North East England
Posts: 46 Silver Machine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
error in your SQL syntax near

Help please, this script runs through fine gives me confirmation in an HTML page with the correct variables written in but does not up date the data base. The message may be SQL syntax but I haven’t got a clue! I am using Perl MySql and Apache. Any one got any Ideas. The ‘M’ Is the value I was sending for $Sex and ‘Y’ Is the value I was sending for $Maturity. So it must be that bit. I get the same with Commas added. Sex =?,
Maturity =?,
Age =?,
Length =?,
Notes =?
I can not find an example of using IN this way with variables has anyone done this? Any comments please, or references, C pan, Dev Shed and MySql manual I have examined, I may have missed something. I have probably looked so hard I have missed the obvious. Anything please Chris



error in your SQL syntax near '(UPDATE Guide SET Sex ='M',
[Fri Jan 09 17:13:31 2004] [error] [client 127.0.0.1] Maturity ='Y',
[Fri Jan 09 17:13:31 2004] [error] [client 127.0.0.1] ' at line 1 at C:/Program Files/Apache Group/Apache2/cgi-bin/Guide_edit.pl line 28.


#!c:\perl\bin\perl.exe
use CGI ":standard";
$Code=param("Code");
$Name=param("Name");
$Family=param("Family");
$Sex=param("Sex");
$Maturity=param("Maturity");
$Age=param("Age");
$Length=param("Length");
$Notes=param("Notes");
open (OUTFILE, ">>Guide_edit.txt");
print OUTFILE "$Code $Name $Family $Sex $Maturity $Age $Length $Notes\n";
close (OUTFILE);
use DBI;
$DBH = DBI->connect("DBI:mysql:Guide") or die "\n ($DBI::err) : $DBI::errstr\n";
my $query = $DBH ->prepare(qq{(UPDATE Guide SET Sex =?,
Maturity =?,
Age =?,
Length =?,
Notes =? )
WHERE ? IN (Select Code
FROM Guide
WHERE Code like ?
AND Name like ?
AND Guide.Family like ?)
});

$query->execute($Sex, $Maturity, $Age, $Length, $Notes,$Code,$Code,$Name, $Family);
$query->finish();
$DBH->disconnect();

Reply With Quote
  #2  
Old January 9th, 2004, 03:54 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,696 r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 6 Days 16 h 40 m 48 sec
Reputation Power: 986
WHERE x IN (subselect) will only work in mysql 4.1+
__________________
r937.com | rudy.ca

Reply With Quote
  #3  
Old January 10th, 2004, 05:03 AM
Silver Machine Silver Machine is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: North East England
Posts: 46 Silver Machine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Thanks I have been on ages with this, I am not sure what mine is it says Release: mysql-3.23.38
I assume this is to lower. I will have to work out another way now.
Chris

Reply With Quote
  #4  
Old January 10th, 2004, 05:15 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,696 r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 6 Days 16 h 40 m 48 sec
Reputation Power: 986
you can use WHERE x IN (list of values)

just retrieve the list of values in a separate SELECT query

Reply With Quote
  #5  
Old January 11th, 2004, 04:15 AM
Silver Machine Silver Machine is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: North East England
Posts: 46 Silver Machine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Re hashed the lot before I Read that! Know the next time thanks, Chris

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > error in your SQL syntax near


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway