hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Need MySQL help
Reply

Forum Jump

Need MySQL help

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 10-03-2003, 03:58 PM
Tatha Tatha is offline
Newbie
 
Join Date: Aug 2003
Location: Western Australia
Posts: 5

Need MySQL help


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



Sponsored Links
  #2  
Old 10-03-2003, 04:11 PM
Kattilyn Kattilyn is offline
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..?

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

Sponsored Links
  #4  
Old 10-03-2003, 04:17 PM
Kattilyn Kattilyn is offline
Junior Guru Wannabe
 
Join Date: Sep 2003
Posts: 64
What is $sql set to before these lines?

  #5  
Old 10-03-2003, 04:21 PM
null null is offline
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

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

  #7  
Old 10-03-2003, 05:07 PM
Kattilyn Kattilyn is offline
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.

  #8  
Old 10-03-2003, 05:12 PM
Burhan Burhan is offline
Community Guide
 
Join Date: Jul 2003
Location: Kuwait
Posts: 5,099
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

Reply

Related posts from TheWhir.com
Title Type Date Posted
Google Releases Hosted Database Service Cloud SQL to General Availability Web Hosting News 2014-02-12 13:46:02
Google Cloud Provides Support For Native MySQL Connections Web Hosting News 2013-11-01 14:36:06
Web Hosting Sales and Promos Roundup - September 20, 2013 Web Hosting News 2013-09-20 18:35:29
Hackers Pack More Sophistication into Simple Scripts to Attack PHP Applications Web Hosting News 2013-09-09 11:52:48
PHP And MySQL Scaling: Preparing A Startup For Growth Blog 2013-08-19 12:25:00


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?