runnerjp Posted November 15, 2006 Share Posted November 15, 2006 hey guys iv got this marquee script that takes messages from my database that is a shoutbox and posts them onto my main pageor this is what its supposed to do[code]<?php#################################include("http://runnerselite.com/tag/admin/connect.php");#################################//mysql_connect("$host","$dbuser","$dbpass") or die(mysql_error());mysql_connect(localhost,user,password) or die(mysql_error()); <--i changed this for this forum purpose lol// Select the database.mysql_select_db(runnerse_shoutbox) or die(mysql_error());$query = "SELECT name, message FROM dawg_tag order by postid DESC LIMIT 1";$result = mysql_query($query) or die(mysql_error());$marquee = "";$i = 0;$r=mysql_fetch_array($result);while($r=mysql_fetch_array($result)){ $posts[$i] = $r[name].' - '. $r[message]. ' '; ++$i;}$marquee = implode("<img src='http://www.runnerselite.com/image/RUNNERSMALL.jpg'>", $posts);echo "<marquee scrolldelay='110'><font size='3'><span style='color: white'>". $marquee. "</span></font></marquee>"[/code]the error reads Warning: implode(): Bad arguments. in /home/runnerse/public_html/tag/maq.php on line 24now i think its because the loop never gets a true value (mysql_fetch_array() failed) and thus $posts is never assigned a value, thus $posts isnt an array. yet i have tried messing around with it and cant seem to fix it :(any help guys would be very greatfull Link to comment https://forums.phpfreaks.com/topic/27321-i-need-help-with-silly-script-haha/ Share on other sites More sharing options...
runnerjp Posted November 15, 2006 Author Share Posted November 15, 2006 any ideas how i can solve this anyone ?? :( Link to comment https://forums.phpfreaks.com/topic/27321-i-need-help-with-silly-script-haha/#findComment-124923 Share on other sites More sharing options...
trq Posted November 15, 2006 Share Posted November 15, 2006 You have your query limitted to one record, then your calling mysql_fetch_array outside of the loop. By the time its gets to the loop there are no records left.Which is it? If you only want one record you dont need half this code... if you have more than one record, remove the LIMIT clause from your query and also the call to mysql_fetch_array from before the while(). Link to comment https://forums.phpfreaks.com/topic/27321-i-need-help-with-silly-script-haha/#findComment-124934 Share on other sites More sharing options...
Orio Posted November 15, 2006 Share Posted November 15, 2006 Try this:[code]<?phpinclude("http://runnerselite.com/tag/admin/connect.php");mysql_connect($host,$dbuser,$dbpass) or die(mysql_error());mysql_select_db(runnerse_shoutbox) or die(mysql_error());$query = "SELECT name, message FROM dawg_tag order by postid DESC LIMIT 1";$result = mysql_query($query) or die(mysql_error());$marquee = "";$i = 0;$posts = array();while($r=mysql_fetch_array($result)) $posts[] = $r['name'].' - '. $r['message']. ' ';$marquee = implode("<img src='http://www.runnerselite.com/image/RUNNERSMALL.jpg'>", $posts);echo "<marquee scrolldelay='110'><font size='3'><span style='color: white'>". $marquee. "</span></font></marquee>"?>[/code]Orio. Link to comment https://forums.phpfreaks.com/topic/27321-i-need-help-with-silly-script-haha/#findComment-124941 Share on other sites More sharing options...
trq Posted November 15, 2006 Share Posted November 15, 2006 You dont need a loop if your only retrieving 1 record. Makes no sense. Link to comment https://forums.phpfreaks.com/topic/27321-i-need-help-with-silly-script-haha/#findComment-124944 Share on other sites More sharing options...
Orio Posted November 15, 2006 Share Posted November 15, 2006 But this will work if he changes the query to select everything for an example. It doesnt really matter if the script will always select a single record, although it's nicer not to have a loop.Orio. Link to comment https://forums.phpfreaks.com/topic/27321-i-need-help-with-silly-script-haha/#findComment-124945 Share on other sites More sharing options...
trq Posted November 15, 2006 Share Posted November 15, 2006 [quote]although it's nicer not to have a loop[/quote]And much less inifficient if not required. I do however assume (as you do) {s,}he meens to have more than one record. Link to comment https://forums.phpfreaks.com/topic/27321-i-need-help-with-silly-script-haha/#findComment-124951 Share on other sites More sharing options...
runnerjp Posted November 15, 2006 Author Share Posted November 15, 2006 ow yer that worked ...cheers loads orio!!!!!!reaosn its got loop for just 1 thing is because i was testing it out with just 1 message :D:D (correct thorp haha)thanks loads again!! Link to comment https://forums.phpfreaks.com/topic/27321-i-need-help-with-silly-script-haha/#findComment-124954 Share on other sites More sharing options...
trq Posted November 15, 2006 Share Posted November 15, 2006 Well it was that one record LIMIT coupled with your call to mysql_fetch_array outside of the loop that was your problem. Link to comment https://forums.phpfreaks.com/topic/27321-i-need-help-with-silly-script-haha/#findComment-124957 Share on other sites More sharing options...
Jenk Posted November 15, 2006 Share Posted November 15, 2006 Was there any particular reason for multiple threads with the same question? Link to comment https://forums.phpfreaks.com/topic/27321-i-need-help-with-silly-script-haha/#findComment-124959 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.