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
Need help with basic sql
Hi,
I am using oracle 10g, and having some small doubts related to sql , here goes the si
apart from cron
I need to run a php file every one hour. Is there any other solution apart from cron job?
Escape Latin Characters
I need to escape latin characters in an xml doc. Example: "é" is escaped to "é". I thoug
How to show the difference between two data field in a database with php.
Hello php gurus,
how r u all... i'm not so well facing a typical problem please help me...<
Inserting 100x and 100y coordinates in mysql table - easy
Is there a way to insert this data into a mysql table named 'map' with the fields: 'x int 3' , 'y in
Find only certain URLs from page ... regex (semi-complete script)
Hi guys,
What I need to do is take a page & extract all the URLs from the page &a
Table control is disappearing from Screen
Hi Experts,
I have a screen with multiple table control(TC). Each table control has two c
Error when call dll from oracle
Hi all, please help me!
I have dll write C language, I want call it from oracle procedur
Multiple Options for a Single Page
For this example I want to use the Handlers option which is under Fed Admin and all the related codi
CURL XML Request [From C to PHP]
Hi,
I need some help converting this into something that will work with PHP.
Code: #