
10-03-2003, 03:58 PM
|
|
Newbie
|
|
Join Date: Aug 2003
Location: Western Australia
Posts: 5
|
|
Hi everyone,
I need some help with a MySQL/php form, it's complaining about something I've just added and I can't work out what's wrong. Here's the error I got:
You have an error in your SQL syntax near 'bureauinf='0', churchinf='0', financeinf='0', healthinf='0', highinf='0', indust' at line 1** 1064
And here's the code for what I added:
Code:
$bureauinf=$data['bureauinf'];$churchinf=$data['churchinf'];
$financeinf=$data['financeinf'];$healthinf=$data['healthinf'];
$highinf=$data['highinf'];$industryinf=$data['industryinf'];
$legalinf=$data['legalinf'];$mediainf=$data['mediainf'];
$occultinf=$data['occultinf'];$policeinf=$data['policeinf'];
$politicsinf=$data['politicsinf'];$streetinf=$data['streetinf'];
$transportinf=$data['transportinf'];$underworldinf=$data['underworldinf'];
$universityinf=$data['universityinf'];
$sql=$sql."bureauinf='$bureauinf', churchinf='$churchinf', financeinf='$financeinf', healthinf='$healthinf', ";
$sql=$sql."highinf='$highinf', industryinf='$industryinf', legalinf='$legalinf', mediainf='$mediainf', ";
$sql=$sql."occultinf='$occultinf', policeinf='$policeinf', politicsinf='$politicsinf', streetinf='$streetinf', ";
$sql=$sql."transportinf='$transportinf', underworldinf='$underworldinf', universityinf='$unversityinf', ";
$result=mysql_query($sql);
Can anyone see what I did wrong?
Tatha
|

10-03-2003, 04:11 PM
|
|
Junior Guru Wannabe
|
|
Join Date: Sep 2003
Posts: 64
|
|
You're ending the SQL query with a comma AND not terminating it with a semicolon, for starters..?
|

10-03-2003, 04:14 PM
|
|
Newbie
|
|
Join Date: Aug 2003
Location: Western Australia
Posts: 5
|
|
I saw that and fixed it, but it's still giving me grief
|

10-03-2003, 04:17 PM
|
|
Junior Guru Wannabe
|
|
Join Date: Sep 2003
Posts: 64
|
|
What is $sql set to before these lines?
|

10-03-2003, 04:21 PM
|
|
Web Hosting Master
|
|
Join Date: Sep 2002
Location: Illinois
Posts: 2,305
|
|
PHP Code:
$sql = "SELECT * FROM table WHERE ";
$bureauinf=$data['bureauinf'];
$churchinf=$data['churchinf'];
$financeinf=$data['financeinf'];
$healthinf=$data['healthinf'];
$highinf=$data['highinf'];
$industryinf=$data['industryinf'];
$legalinf=$data['legalinf'];
$mediainf=$data['mediainf'];
$occultinf=$data['occultinf'];
$policeinf=$data['policeinf'];
$politicsinf=$data['politicsinf'];
$streetinf=$data['streetinf'];
$transportinf=$data['transportinf'];
$underworldinf=$data['underworldinf'];
$universityinf=$data['universityinf'];
$sql .= "bureauinf = '\$bureauinf', churchinf = '\$churchinf', financeinf = '\$financeinf', healthinf = '\$healthinf', ";
$sql .= "highinf = '\$highinf', industryinf = '\$industryinf', legalinf ='\$legalinf', mediainf = '\$mediainf', ";
$sql .= "occultinf = '\$occultinf', policeinf = '\$policeinf', politicsinf = '\$politicsinf', streetinf = '\$streetinf', ";
$sql .= "transportinf = '\$transportinf', underworldinf = '\$underworldinf', universityinf = '\$unversityinf'";
$result=mysql_query($sql);
__________________
How's my programming? Call 1-800-DEV-NULL
|

10-03-2003, 04:22 PM
|
|
Newbie
|
|
Join Date: Aug 2003
Location: Western Australia
Posts: 5
|
|
Code:
$sql="Select * from charsheets where name='$charname'";
|

10-03-2003, 05:07 PM
|
|
Junior Guru Wannabe
|
|
Join Date: Sep 2003
Posts: 64
|
|
First, scratch those slashes you've added in there before each $.
Second, there is no space between
Code:
$sql = "Select * from charsheets WHERE name='$charname'";
And the next
Code:
$sql .= "bureainf blah blah";
There needs to be a space.. but more important, there needs to be an AND or an OR, not a comma..
Example:
Code:
$sql = "SELECT * FROM charsheets WHERE name='$charname'";
$sql .= " AND bureauinf='$bureauinf' AND churchinf='$churchinf' AND financeinf='$financeinf'";
Can substitute OR for AND. See http://www.mysql.com/doc/en/Selecting_rows.html for more information.
|

10-03-2003, 05:12 PM
|
|
Community Guide
|
|
Join Date: Jul 2003
Location: Kuwait
Posts: 5,100
|
|
You don't need a semicolon at the end of your query, iirc, it will not execute with a semicolon at the end. You however do need a semicolon to terminate the statement.
PHP Code:
// Not this
$query = "SELECT * FROM table WHERE field = 'value';";
//But this
$query = "SELECT * FROM table WHERE field = 'value'";
__________________
In order to understand recursion, one must first understand recursion.
If you feel like it, you can read my blog
Signal > Noise
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
| Postbit Selector |
|
|
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
|
|
|
|
|
|
| Login: |
|
|
| Advertisement: |
|
|
| Web Hosting News: |
|
|
|