Add User script "Could not execute query"
Posted on
16th Feb 2014 07:03 pm by
admin
This should be an easy script but I can't get it to run. Can someone please help me?
<html><head><title>Adding a User</title></head>
<body>
<?php
$self = $_SERVER['PHP_SELF'];
$first_name = $_POST['firstname'];
$last_name = $_POST['lastname'];
$user_email = $_POST['useremail'];
if( (!$first_name) or (!$last_name) or (!$user_email) )
{
$form ="Please enter all new user details...";
$form.="<form action="$self"";
$form.=" method="post">First Name: ";
$form.="<input type="text" name="firstname"";
$form.=" value="$first_name">
Last Name: ";
$form.="<input type="text" name="lastname"";
$form.=" value="$last_name">
Email: ";
$form.="<input type="text" name="useremail"";
$form.=" value="$user_email">
";
$form.="<input type="submit" value="Submit">";
$form.="</form>";
echo($form);
}
else
{
#connect to MySQL
$conn = @mysql_connect("localhost","xxxx","xxxx")
or die("Could not connect to MySQL");
#select a database
$db = @mysql_select_db("xxxx",$conn)
or die("Could not select database");
#create the SQL query
$sql = "insert into tablename (firstname, lastname, useremail)
values ("$first_name",'"$last_name","$user_email" )";
#execute the query
$result = @mysql_query($sql,$conn)
or die("Could not execute query");
if($result)
{ echo("New user $user_email added"); }
}
?>
</body></html>
No comments posted yet
Your Answer:
Login to answer
331
7
Other forums
parse error
On my local machine I keep getting parse error for my footer. When I put it online, it doesn't show
shoping cart issues
i´ve wrote this and works when i add an item to, my cart, but when i want to add othrer item just
Email/MMS to Site
Hey guys. I'm looking for a way for a user to upload images and/or text via their cell phones. It
distinct rows
Hi
version 10.2.0.3
I have a query output something like the following
ID
How to use Ajax to verify data on a DB ?
Hello everyone, well i want to know how to check a value if it exists or not on a Data base and capt
need help with mail()
hi i want to send an email with attaching pdf file using php. i have the following script but the pr
duplicate record notification
In my database, after insertion of records, I want to know if the record inserted is duplicate or no
FTP Programs
Here is a list of commonly suggested FTP Programs to use:
FileZilla
SmartFTP
CuteFTP
Help on Order Entry Form/System Where is best to begin.
I have a dilema and a very short amount of time at this point and I'm looking for some help on decid
pagination numbering pattern
Hello,
I have following code which works great for pagination. but i have small issue now.