vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Help with widget code (https://vborg.vbsupport.ru/showthread.php?t=286996)

dsantana 08-23-2012 10:06 PM

Help with widget code
 
I have this code that is in a php widget to go and gather up to 5 random images.
But it's placing the images in the header instead of the php box.
Any ideas on why that's happening?
I did notice all this code is "msql" and my db is "mysqli" not sure if that matters?
Code:

$con = mysql_connect("*****.**.*******.hostedresource.com","*******","******");
        if (!$con)
        {
                die('Could not connect: ' . mysql_error());
        }

        mysql_select_db("******", $con);
       
        $result = mysql_query("SELECT * FROM vjb_ads ORDER BY RAND() LIMIT 0,5;");
       
        while($row = mysql_fetch_array($result))
        {

                echo "<a href='{$row['url']}'><img src='{$row['image_path']}' /></a><br/>";
               
        }
       
        mysql_close($con);


kh99 08-24-2012 11:24 AM

You can't echo your html, you have to set $output. In your code I think you just have to change "echo" to "$output .= ", like:

Code:

                $output .= "<a href='{$row['url']}'><img src='{$row['image_path']}' /></a><br/>";

dsantana 08-24-2012 03:25 PM

Quote:

Originally Posted by kh99 (Post 2359577)
You can't echo your html, you have to set $output. In your code I think you just have to change "echo" to "$output .= ", like:

Code:

                $output .= "<a href='{$row['url']}'><img src='{$row['image_path']}' /></a><br/>";

Thanks... That got them out of the header but they aren't appearing in the PHP Widget Box either :confused:

Nevermind!!! That worked!!! Missed the "=" when I copy and pasted...

Thanks a bunch!!!

--------------- Added [DATE]1345910120[/DATE] at [TIME]1345910120[/TIME] ---------------

Quote:

Originally Posted by kh99 (Post 2359577)
You can't echo your html, you have to set $output. In your code I think you just have to change "echo" to "$output .= ", like:

Code:

                $output .= "<a href='{$row['url']}'><img src='{$row['image_path']}' /></a><br/>";

On that same line I tried to add standard html code to open in a new window
Code:

<a href='{$row['url']}'" target="_blank">
but it didn't fly, got a syntax error.

What did I do wrong?

kh99 08-26-2012 10:56 PM

You used double quotes in your html. Since you're putting the code in a double quoted string, you either have to escape all double quotes that occur as part ofthe html (by putting a backslash in front on each one) or else use only single quotes (probably the easier option).

dsantana 08-27-2012 03:39 AM

Quote:

Originally Posted by kh99 (Post 2360295)
You used double quotes in your html. Since you're putting the code in a double quoted string, you either have to escape all double quotes that occur as part ofthe html (by putting a backslash in front on each one) or else use only single quotes (probably the easier option).

Thanks... That worked!

dsantana 08-31-2012 03:05 PM

Is there something in that code that might stop an animated gif in Google Chrome?
It works fine in IE and FF


All times are GMT. The time now is 04:48 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01757 seconds
  • Memory Usage 1,729KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete