Jump to content

Archived

This topic is now archived and is closed to further replies.

tecdesign

inserting data into a database

Recommended Posts

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

Share this post


Link to post
Share on other sites
You forgot to invoke the actual query. Example:

$result = mysql_query($sql);

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
[!--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) [snapback]359160[/snapback][/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.

:)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.