sbo Posted December 23, 2006 Share Posted December 23, 2006 Hi,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 37Help is greatly needed !!Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/31694-help-needed-with-this-script/ Share on other sites More sharing options...
chiprivers Posted December 23, 2006 Share Posted December 23, 2006 should it read ?while ($row = mysql_fetch_array($result)) { Quote Link to comment https://forums.phpfreaks.com/topic/31694-help-needed-with-this-script/#findComment-146900 Share on other sites More sharing options...
sbo Posted December 23, 2006 Author Share Posted December 23, 2006 Sorry, i am a very beginner; i don't know what you mean.Would a full capture of the script help ?Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/31694-help-needed-with-this-script/#findComment-146906 Share on other sites More sharing options...
chiprivers Posted December 23, 2006 Share Posted December 23, 2006 try changing the 'if' to a 'while' Quote Link to comment https://forums.phpfreaks.com/topic/31694-help-needed-with-this-script/#findComment-146909 Share on other sites More sharing options...
Jessica Posted December 23, 2006 Share Posted December 23, 2006 It tells you the problemWarning: mysql_fetch_array(): supplied argument is not a valid MySQL result resourceWhat does this mean? Well, your $result variable is not a valid resource. I think your connection: $db = database_connect(); is failing.Also, there's a forum for third party stuff :http://www.phpfreaks.com/forums/index.php/board,34.0.html :) Quote Link to comment https://forums.phpfreaks.com/topic/31694-help-needed-with-this-script/#findComment-146925 Share on other sites More sharing options...
sbo Posted December 23, 2006 Author Share Posted December 23, 2006 I have tried with 'while', it gives the same message.I have tried :$result = mysql_query($sql, $db) or die(mysql_error());The page returns :Unknown column 'l.current_holder' in 'on clause'Really don't know what to do ... Quote Link to comment https://forums.phpfreaks.com/topic/31694-help-needed-with-this-script/#findComment-146947 Share on other sites More sharing options...
Jessica Posted December 23, 2006 Share Posted December 23, 2006 Then you need to think a bit more...you're getting very descriptive errors and ignoring them.It says there is an unknown column. Look at your sql. Does dlp_library have a column called current_holder?I don't know JOINS very well, you should read up on them to make sure your query is right. The problem is in your SQL. Quote Link to comment https://forums.phpfreaks.com/topic/31694-help-needed-with-this-script/#findComment-146952 Share on other sites More sharing options...
sbo Posted December 23, 2006 Author Share Posted December 23, 2006 I have already checked the column 'current_holder' of course.Messages are very descriptive but they do not reveale the real problem.Ok, i think i have a problem with the version of PHP, or syntax, or i don't know ...This script works fine under PHP4 with the same database ... Quote Link to comment https://forums.phpfreaks.com/topic/31694-help-needed-with-this-script/#findComment-146980 Share on other sites More sharing options...
legohead6 Posted December 23, 2006 Share Posted December 23, 2006 also u need to fill in ur username password and database names in database_connect[code]function Book($id) {$this->id = $id;$db = database_connect(username,password,database);$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"]);}}line (37) :while($row = mysql_fetch_array($result)) {[/code] Quote Link to comment https://forums.phpfreaks.com/topic/31694-help-needed-with-this-script/#findComment-146983 Share on other sites More sharing options...
chiprivers Posted December 23, 2006 Share Posted December 23, 2006 i might be wrong but you have used this line$db = database_connect();but supplied no arguments? Quote Link to comment https://forums.phpfreaks.com/topic/31694-help-needed-with-this-script/#findComment-146993 Share on other sites More sharing options...
sbo Posted December 23, 2006 Author Share Posted December 23, 2006 I finally found the solution :http://www.oscommerce-fr.info/faq/qa_info.php?qID=198This 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"; Quote Link to comment https://forums.phpfreaks.com/topic/31694-help-needed-with-this-script/#findComment-146994 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.