News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Yet another php/html question

Started by Thunderace, June 12, 2005, 10:04:28 AM

Previous topic - Next topic

Thunderace

Sorry for all the posts but i'm learning  :D

This works in pure html

   <hr width=70%>
   <?=$filelist?>
   <hr width=70%>


This doesn't work with echo ' ..

echo '<hr width=70%>'=$filelist'<hr width=70%>';

Error is ..
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';'

Help again appreciated please  :D

MrCue

echo '<hr width=70%>' . $filelist . '<hr width=70%>';
I am neither a Pessimist nor an Optimist, Just a Realist.

Eve-Online Forum | View Latest Eve-Online Kills | Site Map | SMF Installation


Saleh

are you sure you replaced the code with MrCue's one?? because it's 100% correct in syntax!
might be another line!?

We don't need a reason to help people

Thunderace

Nope it's that line

this is the code for $filelist ..

$handle=opendir($upload_dir);
$filelist = "";
while ($file = readdir($handle)) {
   if(!is_dir($file) && !is_link($file)) {
      $filelist .= "<a href='$upload_dir$file'>".$file."</a>";
      if ($DELETABLE)
        $filelist .= " <a href='?del=$upload_dir$file' title='delete'>x</a>";
      $filelist .= "<sub><small><small><font color=grey>  ".date("d-m H:i", filemtime($upload_dir.$file))
                   ."</font></small></small></sub>";
      $filelist .="<br>";
   }
}


It's meant to list the files in the images directory

MrCue

Take a look at these lines, i think they are the ones causing you a problem.
$filelist .= "<a href='$upload_dir$file'>".$file."</a>";
$filelist .= " <a href='?del=$upload_dir$file' title='delete'>x</a>";
I am neither a Pessimist nor an Optimist, Just a Realist.

Eve-Online Forum | View Latest Eve-Online Kills | Site Map | SMF Installation


[Unknown]

<?php

$handle 
opendir($upload_dir);
$filelist '';
while (
$file readdir($handle)) {
   if (!
is_dir($file) && !is_link($file)) {
      
$filelist .= '<a href="' $upload_dir $file '">' $file '</a>';
      if (
$DELETABLE)
        
$filelist .= ' <a href="?del=' $upload_dir $file '" title="delete">x</a>';
      
$filelist .= '<sub><small><small><font color="grey">  ' date('d-m H:i'filemtime($upload_dir $file))
                  . 
'</font></small></small></sub>';
      
$filelist .= '<br>';
   }
}

?>


-[Unknown]

Thunderace

I'll simplify this into definates ..

this works ..

<center>
   <div style="background-color: red;"><?=$_REQUEST[message]?></div>
   <br>
   <br><b>My Pages</b>
   <hr width=20%>
   <?=$filelist?>
   <hr width=20%>
</center>


This doesn't ..

echo '<center>
   <div style="background-color: red;">=$_REQUEST[message]</div>
   <br>
   <br><b>My Pages</b>
   <hr width=20%>
   =$filelist
   <hr width=20%>
</center>';


As it's all part of a function I need it all echo'd

This one is really getting on my nerves  ::)

morph


echo '<center>
   <div style="background-color: red;">', $_REQUEST['message'], '</div>
   <br />
   <br /><b>My Pages</b>
   <hr width="20%">
   ', $filelist, '
   <hr width="20%">
</center>';


Try that :)

Coming soon!

kegobeer

If you echo using single quotes, then variables are not parsed.  If you echo using double quotes, variables are parsed.

$name = 'Dave';
echo '$name likes pizza';

result: $name likes pizza

echo "$name likes pizza";

result: Dave likes pizza

echo $name . ' likes pizza';

result: Dave likes pizza

PHP: Strings - Manual
"The truth of the matter is that you always know the right thing to do. The hard part is doing it." - Norman Schwarzkopf
Posting and you (Click "WATCH THIS MOVIE")

morph

The way that i have shown parses..


<?php

$name 
'Dave';
echo 
'Hello '$name'.. How are you?';

?>


Result: Hello Dave.. How are you?

Try it out if you don't believe me ;)

Coming soon!

Thunderace

#12
Thanks morph

That sorted the
Quote$filelist

however the
Quote$_REQUEST['message']
problem still exists.

echo '<center>
   <div style="background-color: red;">', $_REQUEST['message'] ,'</div>


results in ..

Notice: Undefined index: message in

morph

That means that $_REQUEST['message'] isnt set..

Coming soon!

Christian A. Herrnboeck

Try this...

<?php
echo 'Printing Request vars... \n';
print_r($_REQUEST);
echo 
'\n';
echo 
'Printing GET Vars... \n';
print_r($_GET);
echo 
'\n';
?>



-Christian


Farmers:Producing food for the world!

Advertisement: