function gethotproperty($hot){
        $gethot = "select p.reference_id, p.area, p.area_unit, p.transaction_type,p.property_type,p.property_name,p.address1,p.address2,p.city,p.locality,p.pincode,p.area_in_sqft,p.total_price,p.negotiable,".
                        "p.rate_per_sqft,p.num_bedrooms,p.floor_number,p.intro_image_loc,p.amenities_detail, p.specification_detail, p.location_detail from " . DBConf::getDatabaseSchema() . "property p where p.hot = ".$hot;
        $result = mysql_query($gethot, $this->connection);

        $property = new Property();


        while($row = mysql_fetch_array($result)){
            $property->referenceId = $row['reference_id'];
            $property->transactionType = $row['transaction_type'];
            $property->propertyType = $row['property_type'];
            $property->propertyName = $row['property_name'];
            $property->address1 = $row['address1'];
            $property->address2 = $row['address2'];
            $property->city = $row['city'];
            $property->locality = $row['locality'];
            $property->pinCode = $row['pincode'];
            $property->areaInSqFt = $row['area_in_sqft'];
            $property->area = $row['area'];
            $property->areaUnit = $row['area_unit'];
            $property->totalPrice = $row['total_price'];
            $property->isNegotiable = $row['negotiable'];
            $property->ratePerSqFt = $row['rate_per_sqft'];
            $property->numberOfBedrooms = $row['num_bedrooms'];
            $property->floorNumber = $row['floor_number'];
            $property->amenities = $row['amenities_detail'];
            $property->introImageLocation = $row['intro_image_loc'];
            $property->specificationDetails = $row['specification_detail'];
            $property->locationDetails = $row['location_detail'];

        }
        return $property;
    }

what is wrong with this script.keep getting an error:

mysql_fetch_array(): supplied argument is not a valid MySQL result resource.

Dani AI

Generated

The warning means mysql_query() returned false instead of a valid result resource. As noted, that usually points to a SQL or connection error, and 's hint about a wrong schema/table name or typo is a very common cause. Given 's follow-up ("error solved but nothing displays"), the next step is to determine whether the query actually ran and returned zero rows, or whether the result is being discarded by the PHP logic.

Checklist of focused checks (do these in order):

  • Echo the final SQL string and run it directly in the database (CLI or phpMyAdmin). That shows syntax, schema prefix, missing dot, wrong table name, or unexpected values.
  • Confirm what DBConf::getDatabaseSchema() returns and whether it produces the intended identifier (watch for missing/trailing dot or empty string).
  • Validate the $hot value and type. If hot is numeric, cast with (int)$hot; if it is a string, quote and escape it (or better, use prepared statements).
  • Confirm the connection resource ($this->connection) is valid and the proper database is selected.
  • After mysql_query(), check the call result and row count with mysql_num_rows(). If zero, the query succeeded but matched no rows.
  • If multiple rows are expected, build and return an array of results instead of reusing a single Property instance (reusing one object inside the loop overwrites previous rows).

Quick example patterns (conceptual):

if ($result === false) {
    error_log('MySQL error: ' . mysql_error() . ' -- ' . $sql);
    return null;
}
if (mysql_num_rows($result) === 0) {
    return array(); // no rows found
}
$rows = array();
while ($r = mysql_fetch_assoc($result)) {
    $rows[] = $r;
}
return $rows;

And, if mapping to objects, create a new object per row:

$list = array();
while ($r = mysql_fetch_assoc($result)) {
    $p = new Property();
    $p->referenceId = $r['reference_id'];
    // set other fields...
    $list[] = $p;
}
return $list;

Notes and best practices: enable error reporting during development, log database errors rather than suppressing them, and plan migration from the old mysql_* API to mysqli or PDO with prepared statements to avoid SQL injection and ensure compatibility with modern PHP.

Recommended Answers

All 4 Replies

Looks like an error in your query. Change

$result = mysql_query($gethot, $this->connection);

into

$result = mysql_query($gethot, $this->connection) or die(mysql_error());

to check if I'm right.

Member Avatar for Member #334542

DB name in the config.php may be wrong.
May be a spelling Mistakes in sql statments

yes you were right. Thank you so much. it is solved.No error but not displaying anything.

Member Avatar for Member #334542

Mark the thread solved! if it solved

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.