I am going crazy with this script ...


#1

Bonsoir,

Yesterday morning i decided to install an opensource program to manage my personal library.

It is called Distributed Library Project; it appears to be no longer maintained.

Anyway, it fills all my needs and this is all that matters to me.

I made a fisrt install on a non conected computer under Ubuntu with SQL, PHP, etc. : everything worked fine.

But with the program installed online, i always get an error message.

Part of the script :

function Book($id) {
$this->id = $id;
$db = database_connect();
$sql =
"SELECT holder.username AS holder, holder.feedback AS holderFeedback, " .
"u.username, u.address, u.apartment, u.feedback, u.zipcode, " .
"l.status, l.current_holder, l.date_back, " .
"l.authorfirst, l.authorlast, l.title, l.review, l.section " .
"FROM dlp_library l, dlp_user u " .
"LEFT JOIN dlp_user holder ON (l.current_holder = holder.id) " .
“WHERE l.id = ‘$id’ AND l.user_id = u.id”;

$result = mysql_query($sql, $db);
if ($row = mysql_fetch_array($result)) {
$this->owner = safeHTML($row[“username”]);
$this->address = safeHTML($row[“address”]);
$this->apartment = safeHTML($row[“apartment”]);
$this->feedback = safeHTML($row[“feedback”]);
$this->zipcode = safeHTML($row[“zipcode”]);
$this->status = safeHTML($row[“status”]);
$this->current_holder = safeHTML($row[“current_holder”]);
$this->date_back = safeHTML($row[“date_back”]);
$this->authorfirst = safeHTML($row[“authorfirst”]);
$this->authorlast = safeHTML($row[“authorlast”]);
$this->title = safeHTML($row[“title”]);
$this->review = safeHTML($row[“review”]);
$this->section = safeHTML($row[“section”]);
$this->holder = safeHTML($row[“holder”]);
$this->feedback = safeHTML($row[“feedback”]);
}
}

error line (37) :
if ($row = mysql_fetch_array($result)) {

error on the page :

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home.10.4/xxx/www/biblio/include/Book.inc on line 37

Help is greatly needed !!

Thanks in advance.

St?phane.


#2

I finally found the solution by searching google :
http://www.oscommerce-fr.info/faq/qa_info.php?qID=198

This is the modified script :

function Book($id) {
$this->id = $id;
$db = database_connect();
$sql =
"SELECT holder.username AS holder, holder.feedback AS holderFeedback, " .
"u.username, u.address, u.apartment, u.feedback, u.zipcode, " .
"l.status, l.current_holder, l.date_back, " .
"l.authorfirst, l.authorlast, l.title, l.review, l.section " .
"FROM (dlp_library l, dlp_user u) " .
"LEFT JOIN dlp_user holder ON (l.current_holder = holder.id) " .
“WHERE l.id = ‘$id’ AND l.user_id = u.id”;