Incorrect Database Name Error
Posted: Thu Sep 28, 2006 9:44 am
Hi all,
This is my first post so please forgive any glaringly obvious mistakes!!
I have a simple form that allows a user to enter Name, Telephone number, Company Name and a short message, i want this to then write to a MySQL database but when I click my submit button i get this error returned, even though i know for sure that I am using the correct database.
Error Message Returned:
Connected
Incorrect database name 'insert into log (name1,name2,company, telephone, message) values ('','','','','')'
Can anyone point out what I an doing wrong, im not really sure what else to try!!!!
Thanks in Advance
Here is the code that i am using:
This is my first post so please forgive any glaringly obvious mistakes!!
I have a simple form that allows a user to enter Name, Telephone number, Company Name and a short message, i want this to then write to a MySQL database but when I click my submit button i get this error returned, even though i know for sure that I am using the correct database.
Error Message Returned:
Connected
Incorrect database name 'insert into log (name1,name2,company, telephone, message) values ('','','','','')'
Can anyone point out what I an doing wrong, im not really sure what else to try!!!!
Thanks in Advance
Here is the code that i am using:
Code: Select all
<?php
$_REQUEST["Name1"] . " was used.";
$_REQUEST["Name2"] . " was used.";
$_REQUEST["Company"] . " was used.";
$_REQUEST["Telephone"] . " was used.";
$_REQUEST["Message"] . " was used.";
$_Name1 = $_REQUEST["Name1"];
$_Name2 = $_REQUEST["Name2"];
$_Company = $_REQUEST["Company"];
$_Telephone = $_REQUEST["Telephone"];
$_Message = $_REQUEST["Message"];
$link = mysql_connect('localhost', 'root', 'password') or die(mysql_error());
mysql_select_db("messages") or die(mysql_error());
echo "<b>Connected<br>";
$query = ("insert into log (Name1,Name2,Company, Telephone, Message) VALUES ('$_POST[Name1]','$_POST[Name2]','$_POST[Company]','$_POST[Telephone]','$_POST[Message]')");
if(!mysql_db_query($query,$link)) die(mysql_error());
echo "success in database entry.";
?>