MySQL Forums
Forum List  »  PHP

using php to INSERT INTO
Posted by: david fipp
Date: April 02, 2009 10:10AM

I am very new to all of this but man I am having fun with it. In advanced thanks for your help.

I have the below code in a file. I am not sure why it is not working. The connection is working. When I run it I get a result echoed "Entered" but the information is not in the database?

<?php
include('dbconnection.php');

//insert into users table
$name="test";
$email="testemail@test.com";
$password="test123";

$sql2="INSERT INTO users SET username='$name', email='$email', password='$password'";
$result2=mysql_query(sql2);

if($sql2){
echo"Entered";
}else{
echo"failed";
}
?>

Options: ReplyQuote


Subject
Written By
Posted
using php to INSERT INTO
April 02, 2009 10:10AM
April 03, 2009 06:29PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.