|
|
#1 |
|
Member
Join Date: Mar 2006
Location: United Kingdom
Posts: 89
Rep Power: 13 ![]() |
Hi everyone,
I am working on a newsfeed mod that will display (in ticker tape style) the contents of 'class_products/shortDescription' and 'class_products/price'. When user clicks on ticker tape scroller they will be taken to that listing (viewlisting.php). Can someone check the following script for me, please. Thanks PHP Code:
__________________
Thanks, Don. Version 3.1 Developer May God bless you in mighty ways. |
|
|
|
|
#2 |
|
Moderator
Join Date: Mar 2006
Posts: 3,927
Rep Power: 95 ![]() ![]() |
At a glance it looks alright, id say go ahead and test it.
One thing I would recommend though is in the DB query, only select the fields you need. No sense grabbing all the fields if you only need a couple. Also I would recommend a "WHERE" clause so that it only grabs items that are set to display (ie they are authorized and not expired. Something like this... SELECT shortDescription, dateadded, expiration, display FROM products WHERE expiration > NOW() AND display = 'Y' ORDER BY dateadded
__________________
Larry. (Please note: I am not a 68C employee. I am a customer and volunteer who helps with questions where I can and the forums spam free) Set your site apart from the competition with one of my modules...... Google Map Module | You Tube Module | Google Calendar Module | Event Calendar Module 68 Classifieds Important Links Customer Area | Issue Tracker | Knowledge Base | User Manuals |
|
|
|
|
#3 |
|
Member
Join Date: Mar 2006
Location: United Kingdom
Posts: 89
Rep Power: 13 ![]() |
Thanks, Larry,
I can't get it to work and I think the fault is in this script rather than the .js it is feeding. The reason I asked you to take a look at it is because I don't understand PHP...this was put together after the old style of 'monkey see, monkey do' ![]() Thanks, Don.
__________________
Thanks, Don. Version 3.1 Developer May God bless you in mighty ways. |
|
|
|
|
#4 |
|
Moderator
Join Date: Mar 2006
Posts: 3,927
Rep Power: 95 ![]() ![]() |
What I would do is have the above code in its own php file. Then point a browser to it for debugging purposes.
Couple things, first move your date line above the loop, you dont need to do it every iteration of the loop since the result will all be the same day. Next if your looking to just get day/month/year I think your over complicating things all you need to do is this. $this_date = date("d/m/Y"); In your while loop I would simple add an echo of $out_js to see if your query is returning anything. something like this... PHP Code:
__________________
Larry. (Please note: I am not a 68C employee. I am a customer and volunteer who helps with questions where I can and the forums spam free) Set your site apart from the competition with one of my modules...... Google Map Module | You Tube Module | Google Calendar Module | Event Calendar Module 68 Classifieds Important Links Customer Area | Issue Tracker | Knowledge Base | User Manuals |
|
|
|
|
#5 |
|
Member
Join Date: Mar 2006
Location: United Kingdom
Posts: 89
Rep Power: 13 ![]() |
OK. I made a php file, pointed my browser at it and I got this:-
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /xxx/xxx/htdocs/newsfeed.php on line 22 Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in xxx/xxx/htdocs/newsfeed.php on line 33 I'm totaly in the dark here
__________________
Thanks, Don. Version 3.1 Developer May God bless you in mighty ways. |
|
|
|
|
#6 |
|
Moderator
Join Date: Mar 2006
Posts: 3,927
Rep Power: 95 ![]() ![]() |
Post the code you now have in your file so I can see what line the errors are referring to exactly.
__________________
Larry. (Please note: I am not a 68C employee. I am a customer and volunteer who helps with questions where I can and the forums spam free) Set your site apart from the competition with one of my modules...... Google Map Module | You Tube Module | Google Calendar Module | Event Calendar Module 68 Classifieds Important Links Customer Area | Issue Tracker | Knowledge Base | User Manuals |
|
|
|
|
#7 |
|
Member
Join Date: Mar 2006
Location: United Kingdom
Posts: 89
Rep Power: 13 ![]() |
Thanks.
You will see that I have resorted to the original date method because I think it is to do with the way the .js deals with it. newsfeed.php <?php // Connect To Database $db = "XXX"; $db_host = "localhost"; $db_user = "XXX"; $db_pass = "XXX"; $con = mysql_connect($db_host, $db_user, $db_pass)or die("Connect Error: ".mysql_error()); mysql_select_db($db, $con); // Start Building JavaScript $out_js = "feedno=newfeedtype('#000066',\"ReTex International\",\"http://www.mysite.co.uk\");\n"; // MySQL Query $result = mysql_query("SELECT * FROM products ORDER BY datestamp DESC LIMIT 10"); // Build JavaScript for each item while ($row = mysql_fetch_object($result)) { $out_js .= "newstory(\"".$this_date['mday']."/".$this_date['mon']."/".$this_date['year']."\",\"viewlisting.php?id=".$row->id."\",\"".$row->shortDescription."\",\"".$row->price."\");\n"; $this_date = getdate(); } //while ($row = mysql_fetch_object($result)) { //$out_js .= "newstory(\"".$this_date."\",\"viewlisting.php?id= " .$row->id."\",\"".$row->shortDescription."\",\"".$row->price."\");\n"; //for debugging echo $out_js . "<br />"; // end while loop // Close Connection To Database mysql_free_result($result); mysql_close($con); // Send JavaScript echo $out_js; ?> Resulting in:- Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /usr/home/retex-international.co.uk/htdocs/newsfeed.php on line 21 feedno=newfeedtype('#000066',"ReTex International","http://www.retex-international.co.uk"); Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /usr/home/retex-international.co.uk/htdocs/newsfeed.php on line 37 feedno=newfeedtype('#000066',"ReTex International","http://www.mysite.co.uk"); Thanks.
__________________
Thanks, Don. Version 3.1 Developer May God bless you in mighty ways. Last edited by Don; 04-16-2006 at 07:15 AM. |
|
|
|
|
#8 |
|
Moderator
Join Date: Mar 2006
Posts: 3,927
Rep Power: 95 ![]() ![]() |
Don, you are getting the "supplied argument is not a valid MySQL result resource" error because your query is failing.
You query is..... $result = mysql_query("SELECT * FROM products ORDER BY datestamp DESC LIMIT 10"); "products" is not a complete table name. When you did the installation I beleive there was a prompt for a table prefix which defaulted to class but you may have changed it. The actual table name should be "class_products" so your query should look like this... $result = mysql_query("SELECT * FROM class_products ORDER BY datestamp DESC LIMIT 10"); Additionally you should put in some error checking so it looks like this.... PHP Code:
__________________
Larry. (Please note: I am not a 68C employee. I am a customer and volunteer who helps with questions where I can and the forums spam free) Set your site apart from the competition with one of my modules...... Google Map Module | You Tube Module | Google Calendar Module | Event Calendar Module 68 Classifieds Important Links Customer Area | Issue Tracker | Knowledge Base | User Manuals |
|
|
|
|
#9 |
|
Member
Join Date: Mar 2006
Location: United Kingdom
Posts: 89
Rep Power: 13 ![]() |
I now get:-
Parse error: parse error, unexpected T_EXIT in /usr/home/retex-international.co.uk/htdocs/newsfeed.php on line 17 Line 17 = PHP Code:
__________________
Thanks, Don. Version 3.1 Developer May God bless you in mighty ways. |
|
|
|
|
#10 | |
|
Moderator
Join Date: Mar 2006
Posts: 3,927
Rep Power: 95 ![]() ![]() |
Quote:
__________________
Larry. (Please note: I am not a 68C employee. I am a customer and volunteer who helps with questions where I can and the forums spam free) Set your site apart from the competition with one of my modules...... Google Map Module | You Tube Module | Google Calendar Module | Event Calendar Module 68 Classifieds Important Links Customer Area | Issue Tracker | Knowledge Base | User Manuals |
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| page 2 of 2 not working | GSP | v3.1 Questions & Support | 10 | 03-02-2007 07:00 PM |
| Links Not Working | Scooter | v3.1 Questions & Support | 6 | 11-13-2006 10:36 PM |
| Working with the psd file | GSP | v3.1 Modules & Modifications | 2 | 09-30-2006 06:19 AM |
| Searching by join date not working? | civ | v3.1 Questions & Support | 2 | 07-27-2006 09:00 AM |
| Contact us,Owner, New registration mail not working!! | garysr | v3.1 Questions & Support | 12 | 06-09-2006 04:44 PM |