Wrox Programmer Forums
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 7th, 2011, 11:23 PM
Registered User
 
Join Date: Apr 2011
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default url as a variable

I have had no luck with this all day, someone please help. In the body of my php form I have:

$banner=links_files/image001.gif
<img src="$banner" />

but I do not get my image. I have also tried a few dozen other variations such as

$banner=links_files/image001.gif
<img src="<?echo $banner; ?>">

What am I doing wrong? I just want this to point and display a gif.
 
Old April 8th, 2011, 01:00 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Try
Code:
<?php
$banner = "links_files/image001.gif";
echo "<img src=". $banner . ">"; 
?>
__________________
Om Prakash Pant
Click the "Thanks" button if this post helped you.
The Following User Says Thank You to om_prakash For This Useful Post:
Joe-Mama (April 10th, 2011)
 
Old April 10th, 2011, 08:53 PM
Registered User
 
Join Date: Apr 2011
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanks Om,
It was the clue I needed to get started. I am making a template for my my web pages. Each page will have a unique variable setting that will put the right images and such (like the banner on top) for each page. For the sake of anyone else that is getting started and trying to do this here is my variation of Om's code:
On index.php
<?php $banner = "index_files/headline.jpg"; ?>
<?php include "template.php"; ?>

Then in template.php

<?php echo "<img src=". $banner . ">"; ?>

I know it is simple but it helped me get started.
Thanks again Om!





Similar Threads
Thread Thread Starter Forum Replies Last Post
capture variable in URL Lemonluv07 BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 1 March 31st, 2006 04:00 AM
capture a variable from url. .com?jblp jblp PHP How-To 1 October 25th, 2004 07:26 PM
passing a variable through URL katie456 Classic ASP Databases 2 January 20th, 2004 11:27 PM
prevent error if $_GET variable is not in URL mih100 Beginning PHP 1 September 6th, 2003 08:40 PM
catching an URL variable in xslt Flashlight XSLT 1 August 21st, 2003 01:32 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.