Jump to content


Photo

inserting data into a database


  • Please log in to reply
3 replies to this topic

#1 tecdesign

tecdesign
  • Members
  • PipPipPip
  • Advanced Member
  • 33 posts

Posted 28 March 2006 - 02:01 AM

here is the code

<?php

$dbh=mysql_connect ("localhost", "tecdnco_matt", "(password)") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("tecdnco_xtec");

$sql = "INSERT INTO `members` (`username`, `password`, `first_name`, `last_name`, `email_address`, `bizname`, `phone`, `fax`, `street_address`, `country`, `city`, `region`, `mobile`)
VALUES (
'". $_POST['username'] ."',
'". $_POST['password'] ."',
'". $_POST['first_name'] ."',
'". $_POST['last_name'] ."',
'". $_POST['email_address'] ."',
'". $_POST['bizname'] ."',
'". $_POST['phone'] ."',
'". $_POST['fax'] ."',
'". $_POST['street_address'] ."',
'". $_POST['country'] ."',
'". $_POST['city'] ."',
'". $_POST['region'] ."',
'". $_POST['mobile'] ."')";

$username = $_POST['username'];
$password = $_POST['password'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email_address = $_POST['email_address'];
$bizname =$_POST['bizname'];
$phone = $_POST['phone'];
$mobile = $_POST['mobile'];
$fax = $_POST['fax'];
$street_address = $_POST['street_address'];
$country = $_POST['country'];
$region = $_POST['region'];
$city = $_POST['city'];

echo" $password $username $first_name $last_name"
?>

I have taken out the password ok so that is not the problem. What is happeing is that it will not add the data to the database but the $password $username $first_name and $last_name in the echo statement are showing up. I am completely lost and confused

#2 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 28 March 2006 - 03:58 AM

You forgot to invoke the actual query. Example:

$result = mysql_query($sql);



#3 tecdesign

tecdesign
  • Members
  • PipPipPip
  • Advanced Member
  • 33 posts

Posted 28 March 2006 - 05:20 AM

Thanks toplay you're the man it work!

So how do I get really good at PHP, I want to beomce a guru any advice?

#4 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 28 March 2006 - 06:32 AM

[!--quoteo(post=359160:date=Mar 27 2006, 09:20 PM:name=Tec_Matt)--][div class=\'quotetop\']QUOTE(Tec_Matt @ Mar 27 2006, 09:20 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Thanks toplay you're the man it work!

So how do I get really good at PHP, I want to beomce a guru any advice?
[/quote]
You're welcome.

Read, learn, and do. Practice, practice and practice. It comes with time and experience. Be patient.

Just keep coding.

:)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users