Go to Post I like this thread because it means I don't have to leave my house to find something to complain about! - PayneTrain [more]
Home
Go Back   Chief Delphi > Technical > IT / Communications > Website Design/Showcase
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 18-06-2004, 13:07
LBK Rules's Avatar
LBK Rules LBK Rules is offline
1467 '06 Alumni
AKA: Anthony Rinaldi
no team (HSRO)
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2003
Location: Henrico, VA
Posts: 438
LBK Rules will become famous soon enoughLBK Rules will become famous soon enough
ODBC SQL Problem

Well, I started creating a test program that enters data from a HTML table to a database.

I wrote this code, but I keep getting this error:

Quote:
Warning: SQL error: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement., SQL state 37000 in SQLExecDirect in c:\ibserver\www\ucs\create_user.php on line 22
Error in SQL
I can't seem to figure out the problem. I know I have everything setup correctly, and I don't understand why it's not working.

PHP Code:
<?php

//Include Config Information
require("config.php"); 

//Connect to Database
$conn=odbc_connect($dbname,$dbuser,$dbpass);

//If Connection Failed, Show Error Message
if (!$conn)
{
exit(
"Connection Failed: " $conn);


//Insert Data into Database
$sql="INSERT INTO Sellers (Username, Password, LastName, FirstName, Address, City, State, ZIP, Phone, EMail) VALUES ($UserName_TextBox$Password_TextBox$LastName_TextBox$FirstName_TextBox$Address_TextBox$City_TextBox$State_TextBox$ZIP_TextBox$Phone_TextBox$EMail_TextBox)";

$rs=odbc_exec($conn,$sql);
if (!
$rs)

exit(
"Error in SQL");
}

odbc_close($conn);

echo 
"Sucessful!";

?>
Note: I am using ODBC instead of MySQL since I am developing this for a server without MySQL.
__________________
Anthony Rinaldi
Team 1132: 2003
Team 1467: 2004 - 2006
  #2   Spotlight this post!  
Unread 18-06-2004, 23:29
LBK Rules's Avatar
LBK Rules LBK Rules is offline
1467 '06 Alumni
AKA: Anthony Rinaldi
no team (HSRO)
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2003
Location: Henrico, VA
Posts: 438
LBK Rules will become famous soon enoughLBK Rules will become famous soon enough
Re: ODBC SQL Problem

Ok, I have figured it out, with the help of my dad.

I didn't include single-quotes ( this ' ) around the varibles that might have spaces in it.

Example:

PHP Code:
$sql="INSERT INTO Sellers (Username, Password, LastName, FirstName, Address, City, State, ZIP, Phone, EMail) VALUES ('" 
$UserName_TextBox "', '" $Password_TextBox "', '" $LastName_TextBox "', '"  $FirstName_TextBox "', '"  
$Address_TextBox "', '"  $City_TextBox "', '"  $State_TextBox "', '"  $ZIP_TextBox "', '"  $Phone_TextBox .
"', '"  $EMail_TextBox "')"
PHP Code:
$Address_TextBox 
would not work, but
PHP Code:
$rest_of_sql1 ", '" $Address_TextBox "', " $rest_of_sql2 
would.

I hope this helps somebody.
__________________
Anthony Rinaldi
Team 1132: 2003
Team 1467: 2004 - 2006
Closed Thread


Thread Tools
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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help with SQL Tom Bottiglieri Website Design/Showcase 10 01-03-2004 15:49
Victor problem Andy Baker Electrical 15 24-06-2003 09:49
Ok one problem cantwell03 Programming 3 13-02-2003 07:28
The problem with scouting... archiver 2001 10 23-06-2002 23:49
Major problem with chipphua motors aka Scott White Motors 18 19-03-2002 19:44


All times are GMT -5. The time now is 00:28.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi