21
RSearcy
Re: Database tables -- insert codes
  • 2006/2/10 17:51

  • RSearcy

  • Just popping in

  • Posts: 45

  • Since: 2004/3/2 2


grtest2 is supposed to be the username
INSERT INTO pcpin_user 
(login, email, password) VALUES (grtest2, grtest2@grtest2.robertsearcy.info, 284ffbecc619c5d27f3e0067e22e30c1)
Golden-Road.net Error

Error Code
: 0013


ERROR
: Could not query the database. 
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@grtest2.robertsearcy.info, 284ffbecc619c5d27f3e0067e22e30c1)' at line 1

Still didn't do the trick, but at least it looks like we're getting somewhere with it finally, though.

22
wtravel
Re: Database tables -- insert codes

Okay, let's try a next step. It looks like the query is not working because the values are not interpreted as text (at least the e-mail value).

Could you change the sql statement line into:
$sql = sprintf("INSERT INTO %s (login, email, password) VALUES (%s, %s, %s)", 'pcpin_user', ''.$newuser->getvar('uname').'', ''.$newuser->getvar('email').'', ''.$newuser->getvar('pass').'');

If that does not work it could be possible that the e-mail address is too long for the table field, but that is a long shot. First you could try this code.

23
RSearcy
Re: Database tables -- insert codes
  • 2006/2/10 18:07

  • RSearcy

  • Just popping in

  • Posts: 45

  • Since: 2004/3/2 2


grnet2 is supposed to be the username
INSERT INTO xoops_pcpin_user 
(login, email, password) VALUES (grnet2, hosting@robertsearcy.info, 284ffbecc619c5d27f3e0067e22e30c1)
Golden-Road.net Error

Error Code
: 0013


ERROR
: Could not query the database. 
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@robertsearcy.info, 284ffbecc619c5d27f3e0067e22e30c1)' at line 1

Tried it with both the usual email addy and a shorter one (like in the error used above). Still not working.

I did notice, though, that it seems like it's now cutting off at the "@" in the email addy.

24
wtravel
Re: Database tables -- insert codes

Errr, in my response I accidentally copied the old $xoopsDB->prefix() again. I edited my post. From the error code it looks like still still does not accept the input as text though. Could you try without the $xoopsDB->prefix() function?

25
RSearcy
Re: Database tables -- insert codes
  • 2006/2/10 18:21

  • RSearcy

  • Just popping in

  • Posts: 45

  • Since: 2004/3/2 2


Tried it again.

grnet2 is supposed to be the username
INSERT INTO pcpin_user 
(login, email, password) VALUES (grnet2, hosting@robertsearcy.info, 284ffbecc619c5d27f3e0067e22e30c1)
Golden-Road.net Error

Error Code
: 0013


ERROR
: Could not query the database. 
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@robertsearcy.info, 284ffbecc619c5d27f3e0067e22e30c1)' at line 1

Same thing. To me, and I may be wrong being that I don't know very much about PHP and/or MySQL scripting, it seems like there's something wrong at the @ in the email addy. It's always cutting off at the @ in the error message.

26
wtravel
Re: Database tables -- insert codes

Yes, the query should be:

INSERT INTO pcpin_user (login, email, password) VALUES ('grnet2', 'hosting@robertsearcy.info', '284ffbecc619c5d27f3e0067e22e30c1')

So the quotes around the values that need to be inserted should be included in the query.

27
wtravel
Re: Database tables -- insert codes

Since the sql query should have had the quotes around the values I think somehow the older sql code was executed. Can you try the following line for the definition of the sql statement?

$sql = sprintf("INSERT INTO %s (login, email, password) VALUES (%s, %s, %s)", 'pcpin_user', ''.$newuser->getvar('uname').'', ''.$newuser->getvar('email').'', ''.$newuser->getvar('pass').'');

28
RSearcy
Re: Database tables -- insert codes
  • 2006/2/10 19:00

  • RSearcy

  • Just popping in

  • Posts: 45

  • Since: 2004/3/2 2


Tried the new code.

grnet2 is supposed to be the username
INSERT INTO pcpin_user 
(login, email, password) VALUES (grnet2, hosting@robertsearcy.info, 284ffbecc619c5d27f3e0067e22e30c1)
Golden-Road.net Error

Error Code
: 0013


ERROR
: Could not query the database. 
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@robertsearcy.info, 284ffbecc619c5d27f3e0067e22e30c1)' at line 1

Same thing's happening.

29
wtravel
Re: Database tables -- insert codes

After some testing RSearchy and I found the solution in changing the sql code to:
$sql = sprintf("INSERT INTO %s (login, email, password) VALUES (%s, %s, %s)", 'pcpin_user', "'".$uname."'", "'".$email."'", "'".$pass."'");

and adding
$uname = "'".$newuser->getvar('uname')."'";
$pass = "'".$newuser->getvar('pass')."'";
$email = "'".$newuser->getvar('email')."'";
right after //Insert user into PCPIN table

30
RSearcy
Re: Database tables -- insert codes
  • 2006/2/11 3:10

  • RSearcy

  • Just popping in

  • Posts: 45

  • Since: 2004/3/2 2


Tried that. Got this error:

grtest2 is supposed to be the username
INSERT INTO pcpin_user 
(login, email, password) VALUES (''grtest2'', ''grtest2@grtest2.robertsearcy.info'', ''284ffbecc619c5d27f3e0067e22e30c1'')
Golden-Road.net Error

Error Code
: 0013


ERROR
: Could not query the database. 
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'grtest2'', ''grtest2@grtest2.robertsearcy.info'', ''284ffbecc619c5d27f3e0067e22e' at line 1