angel55 Posted May 26, 2009 Share Posted May 26, 2009 Hello, iam getting this error, can anyone plz help. Parse error: parse error, expecting `T_FUNCTION' in C:\xampp\htdocs\Estate\estateagent.php on line 34 this is my code ?> <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post"> Agent ID to update: <input type="text" name="AgentID" /><br /> Enter Agent Name:<input type="text" name="AgentName"/><br /> <input type="submit" value="Save" /> </form> <?php } //end if else { $AgentID = $_POST['AgentID']; $AgentName = $_POST['Agent_Name']; $db1 = new estateagent(); $db1->openDB(); $numofrows = $db1->update_agent($AgentID, $AgentName); echo "Success. Number of rows affected: <strong>{$numofrows}<strong>"; $db1->closeDB(); } ?> Link to comment https://forums.phpfreaks.com/topic/159770-error/ Share on other sites More sharing options...
lonewolf217 Posted May 26, 2009 Share Posted May 26, 2009 there aren't 34 lines here. what line is the error supposed to be on ? Link to comment https://forums.phpfreaks.com/topic/159770-error/#findComment-842753 Share on other sites More sharing options...
angel55 Posted May 27, 2009 Author Share Posted May 27, 2009 i got another error SQL Insertion error: Unknown column 'Tenant_ID' in 'field list' Link to comment https://forums.phpfreaks.com/topic/159770-error/#findComment-843093 Share on other sites More sharing options...
Ken2k7 Posted May 27, 2009 Share Posted May 27, 2009 If you want our help, you're going to have to help us help you. Please post the pertinent code. Link to comment https://forums.phpfreaks.com/topic/159770-error/#findComment-843096 Share on other sites More sharing options...
angel55 Posted May 27, 2009 Author Share Posted May 27, 2009 i HAVE SOLVED THAT ONE. THNX. I GOT ERROR WHICH I CANNOT FIND THE SOLUTION. SQL Insertion error: Cannot add or update a child row: a foreign key constraint fails (`comreg098jayathas`.`properties`, CONSTRAINT `properties_ibfk_1` FOREIGN KEY (`Agent_ID`) REFERENCES `agents` (`Agent_ID`) ON DELETE CASCADE ON UPDATE CASCADE) THIS IS MY FILE <?php require("Config.php"); class properties { private $connection; function __construct() { //Empty constructor } function insert_properties($Type,$Price,$Address,$Postcode,$Photo,$IsAvailable,$Agent_ID) { //$esc_Properties_ID = mysql_real_escape_string($Properties_ID , $this->connection); $esc_Type = mysql_real_escape_string($Type, $this->connection); $esc_Price = mysql_real_escape_string($Price, $this->connection); $esc_Address = mysql_real_escape_string($Address, $this->connection); $esc_Postcode = mysql_real_escape_string($Postcode, $this->connection); $esc_Photo = mysql_real_escape_string($Photo, $this->connection); $esc_IsAvailable = mysql_real_escape_string($IsAvailable, $this->connection); $esc_Agent_ID = mysql_real_escape_string($Agent_ID, $this->connection); $sql="insert into properties(Properties_ID,Type,Price,Address,Postcode,Photo,IsAvailable,Agent_ID) values ('','{$esc_Type}','{$esc_Price}','{$esc_Address}',' {$esc_Postcode}','{$esc_Photo}','{$esc_IsAvailable}','{Agent_ID}')"; $result=mysql_query($sql, $this->connection); if(!$result) { die("SQL Insertion error: " . mysql_error()); } else { $numofrows = mysql_affected_rows($this->connection); return $numofrows; } } function openDB() { $this->connection = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$this->connection) { die("SQL Connection error: " . mysql_error()); } $db_selected = mysql_select_db(DB_NAME, $this->connection); if(!$db_selected) { die("SQL Selection error: " . mysql_error()); } } function closeDB() { mysql_close($this->connection); } function getResult($sql) { $result = mysql_query($sql, $this->connection); if($result) { return $result; } else { die("SQL Retrieve Error: " . mysql_error()); } } } // End of Class agent class ?> <?php if (!$_POST) //page loads for the first time { ?> <form action=" <?php echo $_SERVER['PHP_SELF'] ?>" method="post"> <br /> Type:<input type="text" name="Type" /><br /> <br />Price:<input type="text" name="Price" /><br /> <br />Address:<input type="text" name="Address" /><br /> <br />Postcode:<input type="text" name="Postcode" /><br /> <br />Photo:<input type="file" name="Photo" /><br /> <br />Is Available: <select name="Is available"> <option value="Yes">Yes</option> <option value="No">No</option> </select> <br /> <br />AgentID:<input type=" name="Agent_ID" /><br /> <br /> <input type="submit" value="Save" /> </form> <?php } else { $Type = $_POST['Type']; $Price = $_POST['Price']; $Address = $_POST['Address']; $Postcode = $_POST['Postcode']; $Photo = $_POST['Photo']; $IsAvailable = $_POST['IsAvailable']; $Agent_ID = $_POST['Agent_ID']; $db1 = new properties(); $db1->openDB(); $numofrows = $db1->insert_properties($Type,$Price,$Address,$Postcode,Photo,IsAvailable,Agent_ID); echo "jhhjk"; $db1->closeDB(); } ?> Link to comment https://forums.phpfreaks.com/topic/159770-error/#findComment-843118 Share on other sites More sharing options...
angel55 Posted May 27, 2009 Author Share Posted May 27, 2009 Agent_ID is foreign key in properties table. when i enter any ID number in the agent id the below error appeares.the agent ID that i enter in the properties table does exists in the agent table. SQL Insertion error: Cannot add or update a child row: a foreign key constraint fails (`comreg098jayathas`.`properties`, CONSTRAINT `properties_ibfk_1` FOREIGN KEY (`Agent_ID`) REFERENCES `agents` (`Agent_ID`) ON DELETE CASCADE ON UPDATE CASCADE) Link to comment https://forums.phpfreaks.com/topic/159770-error/#findComment-843132 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.