dark_destroyer Posted September 28, 2006 Share Posted September 28, 2006 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:ConnectedIncorrect database name 'insert into log (name1,name2,company, telephone, message) values ('','','','','')'Here is teh code that i am using:<?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.";?>Can anyone point out what I an doing wrong, im not really sure what else to try!!!!Thanks in Advance Quote Link to comment Share on other sites More sharing options...
thedarkwinter Posted September 28, 2006 Share Posted September 28, 2006 Hi I'm a newbie too - so lets hope in not talking rubbish here!Problem is with the names of the arrays not being in strings: try esacping the names of the arrays using \"$query = ("insert into log (Name1,Name2,Company, Telephone, Message) VALUES ('$_POST[\"Name1\"]','$_POST[\"Name2\"]','$_POST[\"Company\"]','$_POST[\"Telephone\"]','$_POST[\"Message\"]')");Maybe that will work...good luck Quote Link to comment Share on other sites More sharing options...
dark_destroyer Posted January 31, 2007 Author Share Posted January 31, 2007 Thanks!!!! Quote Link to comment Share on other sites More sharing options...
dark_destroyer Posted January 31, 2007 Author Share Posted January 31, 2007 SOLVED Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.