Discussion Locked

php and my sql

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

first of all here is the php code:
http://pastebin.com/251806

Ok, I have the page sorta working after squishing some bugs, i'm left with an anomoly i can't figure out....

If i try to enter text with no spaces into the text boxes and submit, i get this error:

Error adding client data: Unknown column 'asdf' in 'field list'
(asdf is the text i entered into the first box)

if i enter text with spaces:

Error adding client data: You have an error in your SQL syntax near 'sdfs,sdfsd sdfsd,sdf sdfds)' at line 1

However, if i enter numbers with no spaces it works. If i enter numbers with spaces:

Error adding client data: You have an error in your SQL syntax near '654546,5621 654 654,65321 4687)' at line 1

any help would be appreciated

5 replies

by jaqui

the link doesn't show anything.
no php in view source, only a blank html page

by jaqui

first problem is the @ symbol in the mysql commands, it is not needed.

mysql_connect() not @mysql_connect()

second thing I see:
//if ("SUBMIT" == "addclient") {
//$sql = "INSERT INTO cid (name,homeline1,homeline2) VALUES ('$name','$homeline1','$homeline2');
//$sql = "INSERT INTO clients VALUES ('',$name,$homeline1,$homeline2)";

the forward slashes are commenting out the lines.

the third that I see is you are inserting into 2 db/tables?
insert into cid
insert into clients
you only connected to one db, cid.

so:
insert into INSERT INTO cid (name,homeline1,homeline2) VALUES ('$name','$homeline1','$homeline2');

the sql isn't needed.

This discussion is closed to new replies.