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
Displaying values from a SQL count...
Hi,
Easy enough question i just forget the exact method ..
I have ...
Code: //count win
Dynamic Array using glob?
Is there an easier way to do this?
I am trying to get create a dyamic array based on files wi
validating url
im trying to validate url's sent to me by a form
the url's im collecting are for placing banners
How to use Substr
I want to check for the word CATEGORY: inside a string which can be CATEGORY: ITEM
and remove the
Using Curl_multi for processing multiple URLs
Hi,
I am at a loss as to how to implement this. I would like to be able to automatically assi
Else statement screws up all css
Does anyone know what goes wrong in the process with this php code?
This code seems to be causing
undefined offset help
Hi All,
I kept getting undefined offset PHP notice for a simple for loop. For eg
$va = arr
New Search Engine problem
Hey everyone,
I have a ZIP Code Radius search engine already functional. it displays all of t
Issue Parsing XML into table
Hello all,
Im a bit new to php and new to phpfreaks. But thanks in advance for the help!
<
LOOPing Problem
Hello All!
The following code loops through the data and displays the data accordingly. My p