August 22, 2008, 02:59:43 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Add your links to our directory. Click here to add your links.
 
  Home   Forum   Help Search Directory Calendar Login Register    RSS 2.0 feedAtom feed


News
Add your links to our directory. Click here to add your links.
Pages: [1]
  Print  
Author Topic:

What's wrong with this script ?

 (Read 1422 times)
0 Members and 1 Guest are viewing this topic.
sintex
Jr. Member
**

Points: 7
Offline Offline

Posts: 96


« on: June 09, 2006, 20:23:16 »

What's wrong with this code ?
Code:
$query= 'INSERT INTO `plb_ids` (`id`, `user`, `password`, `email`, date) VALUES (NULL, $username, $pass, $email, now());';
mysql_query($query); 

The code is "working" but is inserting in my database $username and $password not the variables.
Any help is appreciated. Thanks
Logged


TheGodFather
Administrator
Hero Member
*****

Points: 202
Offline Offline

Posts: 2570



WWW
« Reply #1 on: June 09, 2006, 21:55:27 »

Try to use double quote " not just ' and change ` wuth '

Regards
Logged

chris3471
Full Member
***

Points: 3
Offline Offline

Posts: 187


WWW
« Reply #2 on: June 09, 2006, 23:18:17 »

What's wrong with this code ?
Code:
$query= 'INSERT INTO `plb_ids` (`id`, `user`, `password`, `email`, date) VALUES (NULL, $username, $pass, $email, now());';
mysql_query($query); 

The code is "working" but is inserting in my database $username and $password not the variables.
Any help is appreciated. Thanks

This should work, you shouldn't need the back quotes either.
Code:
$query= "INSERT INTO plb_ids (id, user, password, email, date)
VALUES ('NULL', '$username', '$pass', '$email', 'now();')";
mysql_query($query);
Logged

Harro
Full Member
***

Points: 2
Offline Offline

Posts: 184



« Reply #3 on: June 11, 2006, 03:39:10 »

Not realy familiar with sql and php. But shouldn't it be this:

Code:
$query= "INSERT INTO plb_ids (id, user, password, email, date)
VALUES ('NULL', '" . $username . "', '" . $pass . "', '". $email . "', '". now() . ";')";
mysql_query($query);
Logged

chris3471
Full Member
***

Points: 3
Offline Offline

Posts: 187


WWW
« Reply #4 on: June 12, 2006, 04:08:46 »

No, what I posted above is correct.
Logged

bernkly
Jr. Member
**

Points: 0
Offline Offline

Posts: 6



WWW
« Reply #5 on: June 17, 2006, 17:33:44 »

I think both chris3471 and Harro style are correct.

I'm usually using the same style as chris3471. Although it was in quote '$username', the php would recognise $ as a variable and get the value from it.  Grin
Logged

sintex
Jr. Member
**

Points: 7
Offline Offline

Posts: 96


« Reply #6 on: August 18, 2006, 00:10:04 »

Thanks for help.
Logged
scolls
Jr. Member
**

Points: 0
Offline Offline

Posts: 19


WWW
« Reply #7 on: November 11, 2006, 00:28:49 »

Not realy familiar with sql and php. But shouldn't it be this:

Code:
$query= "INSERT INTO plb_ids (id, user, password, email, date)
VALUES ('NULL', '" . $username . "', '" . $pass . "', '". $email . "', '". now() . ";')";
mysql_query($query);

This will certainly ensure that the values of the variables are insterted.

Also, since your id field is an auto-increment field, it's unnecesary to insert anything there, eg you can leave out the "id" and "NULL" in your query - the id will still auto-increment. Wink
Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.4 | SMF © 2006, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks

TinyPortal v0.9.7 © Bloc
Valid XHTML 1.0! Valid CSS!