Jump to content

xx_princess_xx

Members
  • Posts

    69
  • Joined

  • Last visited

    Never

About xx_princess_xx

  • Birthday 11/20/1987

Profile Information

  • Gender
    Female

xx_princess_xx's Achievements

Member

Member (2/5)

0

Reputation

  1. INSERT into iqsmart VALUES ('NULL', $_POST['name'], '$points'); you spelt values wrong easy mistake dont wory
  2. ok, yh i made sure, sory of i didnt understand u b4, i'm still getting errors i think i'm gona give up soon,
  3. yh CREATE TABLE Agents ( Agent_ID int(4) NOT NULL Address varchar(40) NOT NULL default 'unknown', Postcode varchar(7) NOT NULL default 'unknown', PRIMARY KEY (Agent_ID) ) ENGINE=INNODB AUTO_INCREMENT=1;
  4. CREATE TABLE Properties ( Properties_ID int(4) NOT NULL auto_increment, Type varchar(20) NOT NULL default 'unknown', Price int( NOT NULL, Address varchar(40) NOT NULL default 'unknown', Postcode varchar(7) NOT NULL default 'unknown', Photo varchar(20) NOT NULL default '', IsAvailable varchar(4) NOT NULL, Agent_ID int(4) NOT NULL, PRIMARY KEY (Properties_ID), FOREIGN KEY (Agent_ID) REFERENCES Agents(Agents_ID) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=INNODB AUTO_INCREMENT=1;
  5. i've have tried entering the right data but still no luck, any ideas
  6. CREATE TABLE IF NOT EXISTS `agents` ( `Agent_ID` int(4) NOT NULL AUTO_INCREMENT, `Agent_Name` varchar(20) DEFAULT NULL, `Address` varchar(40) DEFAULT NULL, `Postcode` varchar(7) DEFAULT NULL, PRIMARY KEY (`Agent_ID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;
  7. this is the sql code i used to create the table CREATE TABLE IF NOT EXISTS `properties` ( `Properties_ID` int(4) NOT NULL AUTO_INCREMENT, `Type` varchar(20) NOT NULL, `Price` float NOT NULL, `Address` varchar(40) NOT NULL, `Postcode` varchar(7) NOT NULL, `Photo` varchar(20) NOT NULL, `IsAvailable` varchar(4) NOT NULL, `Agent_ID` int(4) NOT NULL, PRIMARY KEY (`Properties_ID`), UNIQUE KEY `Agent_ID` (`Agent_ID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=19 ;
  8. my error is 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)
  9. I am trying to insert details from my form to my database and i keep getting an error saying cannot insert or update a child record, <?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('',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:<input type="text" name="IsAvailable" /><br /> <br />AgentID:<input type="text" 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(); } ?>
  10. alright then thanks anyway, its just i need to search my database by photos, so the user can select the photo and then information can be displayed in the results, is there anyway of doing this?
  11. I have the image url stored in my sql database, so far i got this but i think im missing a quote, or apostrope i want the images to be displayed in a drop down menu echo '<option value="<img height='80' width='120' src='".$row['photo']."'">'<img height='80' width='120' src='".$row['photo']."''</option>';
×
×
  • 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.