gfmaking Posted June 23, 2006 Share Posted June 23, 2006 ohhh please can any one help me what is wrong with my code here? I use hTML Form with<form method="post" action="action.php">I saved the following code in action.php file. When submiting the form blank page apears no data inserted. Please some one help me I have a deadline.God bless. <?$username="gfm";$password="cris";$database="Order_db";$host="localhost";$First_Name=$_POST['First_Name'];$Last_Name=$_POST['Last_Name'];$Address=$_POST['Address'];$City=$_POST['City'];$State=$_POST['State'];$Zip=$_POST['Zip'];$Country=$_POST['Country'];$Phone=$_POST['Phone'];$E-Mail=$_POST['E-Mail'];$Product_01=$_POST['Product01'];$Product_02=$_POST['Product02'];$connection = mysql_connect($host,$username,$password)or die( "Unable to connect to server");$db= mysql_select_db($database,$connection) or die( "Unable to select database");$query = "INSERT INTO Order_Form VALUES ($First_Name,$Last_Name,$Address,$City,$State,$Zip,$Country,$phone,$E-mail,$email,$Product01,$Product02);$result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query); // see the problemif($result) { echo "Thank You For your Order";}mysql_close();?> Link to comment https://forums.phpfreaks.com/topic/12708-php-from-help/ Share on other sites More sharing options...
.josh Posted June 23, 2006 Share Posted June 23, 2006 so... what's the error?well i can tell you right now, whatever error you have, here's an error:[code]$query = "INSERT INTO Order_Form VALUES($First_Name,$Last_Name,$Address,$City,$State,$Zip,$Country,$phone,$E-mail,$email,$Product01,$Product02);[/code]needs to be (for example. you need to change it to match your column names):[code]$query = "INSERT INTO Order_Form (First_Name, Last_Name, Address) VALUES ('$First_Name','$Last_Name','$Address')";[/code]you need to have one for one: one column name for one value. I just used the first 3 as an example so i wouldn't have to type it all out. Also, notice the ' ' around the variables (but not the column names) Link to comment https://forums.phpfreaks.com/topic/12708-php-from-help/#findComment-48716 Share on other sites More sharing options...
gfmaking Posted June 23, 2006 Author Share Posted June 23, 2006 Thanks for your time sir,I have made the following change but still showing that blank page....<?$username="gfm";$password="chris";$database="Order_db";$host="localhost";$First_Name=$_POST['First_Name'];$Last_Name=$_POST['Last_Name'];$Address=$_POST['Address'];$City=$_POST['City'];$State=$_POST['State'];$Zip=$_POST['Zip'];$Country=$_POST['Country'];$Phone=$_POST['Phone'];$E-Mail=$_POST['E-Mail'];$Product_01=$_POST['Product01'];$Product_02=$_POST['Product02'];$connection = mysql_connect($host,$username,$password)or die( "Unable to connect to server");$db= mysql_select_db($database,$connection) or die( "Unable to select database");$query = "INSERT INTO Order_Form (First_Name, Last_Name, Address, City, State, Zip, Country, phone, E-mail, Product01, Product02) VALUES ('$First_Name','$Last_Name','$Address','$City','$State','$Zip','$Country','$phone','$E-mail','$Product01','$Product02')";$result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query); // see the problemif($result) { echo "Thank You For your Order";}mysql_close();?> Link to comment https://forums.phpfreaks.com/topic/12708-php-from-help/#findComment-48721 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.