Jump to content


Photo

Php code to insert...


  • Please log in to reply
2 replies to this topic

#1 kevloink

kevloink
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 25 September 2006 - 07:01 AM

I need the php code to insert something into a sql table.
I am using

PHP Version 5.1.7-dev

.


This is the code I am using, and it wont work.
$sql="INSERT INTO users (name, username, password)
VALUES
($name, $user, $pass)";[code][/code]


#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 25 September 2006 - 09:33 AM

string values need to be in quotes
<?php
$sql="INSERT INTO users (name, username, password)
VALUES
('$name', '$user', '$pass')";
mysql_query ($sql) or die (mysql_error());
?>

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 kevloink

kevloink
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 25 September 2006 - 01:37 PM

Thanks, it worked!!!    :D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users