Forum Moderators: coopster
<table>
<tr><td colspan="2"><font SIZE="+0" face="verdana"></td></tr>
<!-- creating the name/id that will be associated with $ID etc-->
<tr><td align="right"><font SIZE="+0" face="verdana">Property ID <input type="text" name="id" id="id"></td></tr>
<tr><td align="right"><font SIZE="+0" face="verdana">Portfolio <input type="text" Portfolio="name" id="Portfolio"></td></tr>
<tr><td align="right"><font SIZE="+0" face="verdana">Town <input type="text" name="Town" id="Town"></td></tr>
<tr><td align="right"><font SIZE="+0" face="verdana">Price <input type="text" name="Price" id="Price"></td></tr>
<tr><td align="right"><font SIZE="+0" face="verdana">Location <input type="text" name="Location" id="Location"></td></tr>
<tr><td align="right"><font SIZE="+0" face="verdana">Size in sqm <input type="text" name="Size" id="Size"></td></tr>
<tr><td align="right"><font SIZE="+0" face="verdana">Condition <input type="text" name="Condition" id="Condition"></td></tr>
<tr><td align="right"><font SIZE="+0" face="verdana">Plotsize <input type="text" name="Plotsize" id="Plotsize"></td></tr>
<tr><td align="right"><font SIZE="+0" face="verdana">Road Access <input type="text" name="Roadaccess" id="Roadaccess"></td></tr>
<tr><td align="right"><font SIZE="+0" face="verdana">Electricity <input type="text" name="Electricity" id="Electricity"></td></tr>
<tr><td align="right"><font SIZE="+0" face="verdana">Water inside <input type="text" name="Water" id="Water"></td></tr>
<tr><td align="right"><font SIZE="+0" face="verdana">Garage <input type="text" name="Garage" id="Garage"></td></tr>
<tr><td align="right"><font SIZE="+0" face="verdana">No. of Bedrooms <input type="text" name="Bedrooms" id="Bedrooms"></td></tr>
<tr><td align="right"><font SIZE="+0" face="verdana">Kitchen <input type="text" name="Kitchen" id="Kitchen"></td></tr>
<tr><td align="right"><font SIZE="+0" face="verdana">WC <input type="text" name="WC" id="WC"></td></tr>
<tr><td align="right"><font SIZE="+0" face="verdana">Picture1 <input type="text" name="pic1" id="pic1"></td></tr>
<tr><td align="right"><font SIZE="+0" face="verdana"><input type="submit" value="ADD New Data"></td></tr>
</table>
</form>
</body>
</html>
and here is the submittedinfo.php
<?
require("./resources/globals.php") ;
require("./resources/common.php");
require("./resources/foots.php");
//Check data
// Connect to the Database
if (!($link=mysql_connect($location,$userName,$password) or die (mysql_error()))) {
DisplayErrMsg(sprintf("error connecting to host %s, by user %s",
$location, $userName)) ;
exit() ;
}
// Select the Database
if (!mysql_select_db($dbname, $link)) {
DisplayErrMsg(sprintf("Error in selecting %s database", $dbname)) ;
DisplayErrMsg(sprintf("error:%d %s", mysql_errno($link), mysql_error($link))) ;
exit() ;
}
// Execute the Statement
if (!($result =mysql_query($selectStmt, $link))) { //where Detail =?
DisplayErrMsg(sprintf("Error in executing %s stmt", $selectStmt)) ;
DisplayErrMsg(sprintf("error:%d %s", mysql_errno($link), mysql_error($link))) ;
exit() ;
}
//$result = mysql_query("select * from Garant");
$sqlquery = "INSERT INTO Garant (id, Portfolio, Town, Price, Location, Size, Condition, Plotsize, Roadaccess, Electricity,
Water, garage, Bedrooms, Kitchen, WC, pic1) VALUES('$_POST[id]','$_POST[Portfolio]','$_POST[Town]','$_POST[Price]','$_POST[Location]','$_POST[Size]','$_POST[Condition]',$_POST[Plotsize]', $_POST[Roadaccess]', $_POST[Electricity]', $_POST[Water]', $_POST[garage]', $_POST[Bedrooms]', $_POST[Kitchen]', $_POST[WC]', $_POST[pic1])";
//Tell mySQL to insert the values from the form into the databse coresponding with the form
$results = mysql_query($sqlquery); //Query the results
mysql_close();
echo "
<html>
<head>
<title> PHP and MySQL </title>
</head>
<body>
<center>
<table border='0' width='500'>
<tr>";
echo " <td>
<font face='verdana' size='+0'>
<center>
<p>You Just Entered This Information Into the Database</p>
</center>";
//display the information that user submitted in the previous form
echo " <blockquote>
<center>
<p>
ID : $id </p> <p>$Town : $Location </p> <p>$Price : $Bedrooms <p> Portfolio </P
</p>
</center>
</blockquote>
</td>
</tr>
</table>
</center>
</body>
</html>";
?>
best regards
Frederick
Here:
// Execute the Statement
if (!($result =mysql_query($selectStmt, $link))) { //where Detail =?
DisplayErrMsg(sprintf("Error in executing %s stmt", $selectStmt)) ;
DisplayErrMsg(sprintf("error:%d %s", mysql_errno($link), mysql_error($link))) ;
exit() ;
}
That's not doing much for you, and where is $selectStmt defined?
Add this line here:
//Tell mySQL to insert the values from the form into the databse coresponding with the form
$results = mysql_query($sqlquery); //Query the results
if(!$results) echo mysql_error();
Or you can integrate it into your error function.
The concatenation that grallis suggests is personal preference. If you structure it the way that you have, you should surround array references with braces:
VALUES('{$_POST[id]}','{$_POST[Portfolio]}',...
$sqlquery = "INSERT INTO
Garant
SET
id = '".$_POST['id']."',
Portfolio = '".$_POST['Portfolio']."',
Town = '".$_POST[Town]."',
Location = '".$_POST['Location']."';
$sqlquery = "INSERT INTO
Garant
SET
id = '{$_POST['id']}',
Portfolio = '{$_POST['Portfolio']}',
Town = '{$_POST[Town])',
Location = '{$_POST['Location']}';
$sqlquery = "INSERT INTO Garant (id, Town, Portfolio, Price, Location, Size, Condition,bedrooms)
VALUES('$_POST['id']','$_POST['Town']','$_POST['Portfolio']','$_POST['price']','$_POST['Location']','$_POST['Size']','$_POST['Condiion']','$_POST['bedrooms']')";
...........
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/public_html/submittedinfo.php on line 55
Regards
Fred
$sqlquery = "INSERT INTO
Garant
SET
id = '{$_POST['id']}',
Portfolio = '{$_POST['Portfolio']}',
Town = '{$_POST[Town]}',
Location = '{$_POST['Location']}'";// You had a close parenthesis instead of a close brace on town and missing closing quote
$sqlquery = "INSERT INTO Garant (id, Town, Portfolio, Price, Location, Size, Condition,bedrooms)
VALUES('{$_POST['id']}','{$_POST['Town']}','{$_POST['Portfolio']}', '{$_POST['price']}','{$_POST['Location']}','{$_POST['Size']}', '{$_POST['Condiion']}','{$_POST['bedrooms']}')";
[edited by: coopster at 7:03 pm (utc) on Oct. 2, 2008]
[edit reason] no urls please TOS [webmasterworld.com] [/edit]
$sqlquery = "INSERT INTO Garant (ID, Town, Portfolio, Price, Location, Size, Condition,bedrooms)
VALUES('{$_POST['ID']}','{$_POST['Town']}','{$_POST['Portfolio']}', '{$_POST['price']}','{$_POST['Location']}','{$_POST['Size']}', '{$_POST['Condiion']}','{$_POST['bedrooms']}')";
Many thanks for all your patient help
Regards
F