shawn.berg -
Joined: 27 May 2004 Posts: 16 Location: Minnesota
|
Posted: Mon Jun 07, 2004 8:11 am Post subject: PHP script won't execute query to MySQL... |
|
|
I'm at a loss. This code I wrote is pretty straight forward, but for some reason will not query with MySQL. This script I wrote, helps me to add new clients to my database QUICKLY. Here is the code:
Code: | <?php
#Define variables
$company='company';
$firstname='firstname';
$lastname='lastname';
$username='username';
$password='password';
if( (!$company) or (!$firstname) or (!$lastname) or (!$username) or (!$password) )
{
echo("Please enter missing information");
}
else
{
#connect to MySQL
$conn = @mysql_connect("localhost","my_username","my_password")
or die("Could not connect to MySQL");
#select a database
$db = @mysql_select_db("clients",$conn)
or die("Could not select database");
#create the SQL query
$sql = "insert into users (company,first_name,last_name,user_name,password)
values (\"$company\",\"$firstname\",\"$lastname\",\"$username\",password(\"$password\") )";
#execute the query
$result = @mysql_query($sql,$conn)
or die("Could not execute query");
if($result)
{ echo("New user $username added"); }
}
?> |
Of course the fields are in an external HTML form. When I press "submit" it comes up "Could not execute Query". Am I just too tired, or am I missing something? My database name is right as is my table name I'm inserting the info into.
Thanks ahead of time!
Shawn.Berg |
|