Jump to content

small code bug help


brad12345

Recommended Posts

hi all im getting this error

Parse error: syntax error, unexpected T_VARIABLE in /home/it224/martinb/public_html/indexbk/newOwner.php on line 60

 

 

 

 

 

$addOwner = $_POST['addOwner'];
$phoneNumber = $_POST['phoneNumber'];
$address = $_POST['address'];
$ownerName = $_POST['ownerName'];
$title = $_POST['title'];




echo("<font face='Arial'>");
$self = $_SERVER['PHP_SELF'];

if (isset($_POST['addOwner'])


	//Insert new owner data into the database martinb 

//Theres something wrong with the below INSERT, can i use the variables as INPUT data from $_POST ???????
	$createQuery1 = "INSERT INTO tblOwnerBK ('title', 'ownerName','address','phoneNumber') VALUES ($title,$ownerName,$address,$phoneNumber)";

 

Line 60 is the last line

Link to comment
https://forums.phpfreaks.com/topic/98788-small-code-bug-help/
Share on other sites

Never trust user input. Always validate or at least use mysql_real_escape_string().

 

<?php
$addOwner = mysql_real_escape_string(stripslashes($_POST['addOwner']));
$phoneNumber = mysql_real_escape_string(stripslashes($_POST['phoneNumber']));
$address = mysql_real_escape_string(stripslashes($_POST['address']));
$ownerName = mysql_real_escape_string(stripslashes($_POST['ownerName']));
$title = mysql_real_escape_string(stripslashes($_POST['title']));
echo "<font face='Arial'>";
$self = $_SERVER['PHP_SELF'];
if (isset($_POST['addOwner']))   // <--- This was your original problem -- you left off the ending parenthesis
	//Insert new owner data into the database martinb 
//Theres something wrong with the below INSERT, can i use the variables as INPUT data from $_POST ???????
	$createQuery1 = "INSERT INTO tblOwnerBK (title, ownerName, address, phoneNumber) VALUES ('$title','$ownerName','$address','$phoneNumber')";
?>

 

Field names should not be in quotes, field values need to be quoted. Use backticks ( ` ) around field names if they are reserved words in MySQL.

 

Ken

Link to comment
https://forums.phpfreaks.com/topic/98788-small-code-bug-help/#findComment-505503
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.