I've been trying and trying to fix this error but can't get it to work.
The error:
Parse error: parse error, unexpected T_STRING in /home/rapid/public_html/directory/CAd.php on line 54
The code:
<?php
class CAd
{
//Constructor for CAd. Gives this class access to MySQL.
function CAd(&$sql)
{
$this->sql = $sql;
}
//Load all of the ad information from the db into class member variables
function LoadAd($id)
{
//Query for the info
$this->sql->query("SELECT * FROM ads where ID = '%s'", $id);
$ad = $this->sql->getrowset();
//"Extract" it into member variables
class_extract($ad[0], $this);
//Throw the ad's category's name into $this->category_name
$this->sql->query("SELECT name FROM categories WHERE ID = '%s'", $this->category);
$this->category_name = $this->sql->getresult();
}
function LoadOwner()
{
//Throw the ad's owner's name into $this->owner_name
$this->sql->query("SELECT * FROM users WHERE ID = '%s'", $this->owner);
$this->owner_data = $this->sql->getrow();
}
//Create a new ad in the MySQL table
function NewAd($owner_id, $title, $category, $price, $info)
{
$this->sql->query("SELECT * FROM ads WHERE title = '%s'", $title);
//Die if there's another ad with the same name
if($this->sql->num_rows != 0)
{
echo "<script>alert('Sorry. Another ad exists with this title. Please choose another title.');</script>";
return FALSE;
}
//Query to add this information into the db
$this->sql->query("INSERT INTO ads SET owner = '%s', title = '%s', category = '%s', price = '%s', info = '%s', date = '%s', $owner_id, $title, $category, $price, $info, time());
return TRUE;
}
//Change an ad's title, price, and info in MySQL
function EditAd($title, $price, $info, $category)
{
$this->sql->query("UPDATE ads SET title = '%s', price = '%s', info = '%s', category = '%s' WHERE ID = '%s', $title, $price, $info, $category, $this->ID);
return TRUE;
}
The following is line 54:
$this->sql->query("UPDATE ads SET title = '%s', price = '%s', info = '%s', category = '%s' WHERE ID = '%s', $title, $price, $info, $category, $this->ID);
Thanks for any help! 🙂