Author Topic: I need a little help with a PHP script  (Read 4983 times)

0 Members and 1 Guest are viewing this topic.

Cammiluna

  • Newbie
  • *
  • Posts: 8
    • View Profile
I need a little help with a PHP script
« on: December 02, 2007, 10:26:47 pm »
I'm in the process of editing my pages. For the most part, it's going okay, but there's this one script I have that completely stopped working.  It's a page with a very small script I use for my art galleries and it allows me to display images and titles to that page without creating a new HTML page for every last image.

It starts off with this:
<?php

if ($_REQUEST['srcs']) {
   ?>


And the second part is this:
<img src="http://cammiluna.xepher.net/portfolio/<?=$_REQUEST['srcs']?>">

It worked just dandy before the server moved, but now any image I load on that page is broken and adding "php" to the request code in the URL isn't doing anything but giving me errors for the "=" in it.  I get rid of the "=" and it's back to the broken image.  I checked the image properties and it asks for that exact url instead of the url for the image I called for.

Is there a possible solution to this? Thanks in advance! <3



« Last Edit: December 02, 2007, 10:30:37 pm by Cammiluna »

Xepher

  • Techsmith
  • Administrator
  • *****
  • Posts: 4,326
  • Illegitimis non carborundum!
    • View Profile
    • Xepher.net
Re: I need a little help with a PHP script
« Reply #1 on: December 03, 2007, 03:05:12 am »
<img src="http://cammiluna.xepher.net/portfolio/<?php echo $_REQUEST['srcs'] ?>">

Cammiluna

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: I need a little help with a PHP script
« Reply #2 on: December 03, 2007, 05:04:03 am »
Wow!

I'm totally up to speed now!  Thanks a TON!

Databits

  • Global Moderator
  • *****
  • Posts: 1,607
  • Programming's not just a science, it's an art.
    • View Profile
Re: I need a little help with a PHP script
« Reply #3 on: December 07, 2007, 11:13:00 pm »
Using <?=$var?> is a totally valid and widely used php variable output method. If it doesn't work your php installation needs to be configured correctly Xeph. :P
(\_/)    ~Relakuyae D'Selemae
(o.O)    
(")_(")  [Libre Office] [Chrome]

Xepher

  • Techsmith
  • Administrator
  • *****
  • Posts: 4,326
  • Illegitimis non carborundum!
    • View Profile
    • Xepher.net
Re: I need a little help with a PHP script
« Reply #4 on: December 07, 2007, 11:38:24 pm »
Using <?=$var?> is only valid if/when the short_open_tag setting is enabled. And if you enable that setting, you then bork any xml pages, since they use the tag <?xml to open code blocks. Granted, you can escape the XML blocks inside a php block using echo, but then "<?='<?xml'?>" is starting to look as unreadable as perl. :-) Bottom line is I can choose to break pages that use the lazier short tags, or break pages that use the lazier (non-escaped) XML tags. (Any code that uses the longer options is, of course, fine either way.) I think no short tags ultimately makes code more readable, so I went that route for the default, but like most things on xepher.net, I try to give as much flexibility as possible. Thus, the short_open_tag setting (along with most others) can be (or at least should be able to be... I haven't actually tried it) overridden in a .htaccess file if you want. http://us2.php.net/manual/en/ini.php has some info on that.
« Last Edit: December 07, 2007, 11:44:21 pm by Xepher »