FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


[PHP] Error link





rafazamboni
Hi friends, I'm a problem with a code PHP, I do not know much thing of this language, only the basic...
Then if somebody will be able to help me...

The code is:


Quote:

<?php

if ($handle = opendir('imagens')) {
while (false !== ($file = readdir($handle))) {

if (strtolower(substr($file,-4,4)) == '.jpg' ||
strtolower(substr($file,-4,4)) == '.gif' ||
strtolower(substr($file,-4,4)) == '.png' ||
strtolower(substr($file,-5,5)) == '.jpeg') {

$alt = 'click to view the image in original size...';
echo '<a href="'.$file.'" target="_blank"><img src="thumb.php?'.$file.'" alt="'.$alt.'" /></a>'."\n";
}
}
closedir($handle);
}

?>



Necessary to modify the following:
<a href="'.$file.'" target="_blank">


Necessary that a new window with specific size is opened, without bars of clod roller, status and others...


I tried to place the following command:
<a href="javascript:;" onClick="window.open('.$file.','resp1','scrollbars=no,width=660,height=505,scrolling=no');">



But when loading the page is indicated error in the modified line...
I do not know what it must be wrong in the code, the shown error is:
-----------------------------------------------------------
parse error, unexpected T_STRING, expecting ',' or ';' in /home/.../test.php on line 35
-----------------------------------------------------------



It will be that somebody can help me, which is the error?
Or somebody knows one another form of for the link as indicated?

Thank U
wumingsden
Don't know much about PHP neither, go to the URL's below, they may help you:

http://uk.php.net/tokens

http://cs-www.bu.edu/help/unix/parse_error.html

http://www.parseerror.com/
rafazamboni
I read the links did not advance very...
Of any very obliged skill...
I find that what would decide the problem would be if somebody knew in one another way of if making one link with those specifications (without bar of status, buttons standard, menus...)

Thanks
thnn
it could be because of the single ' in the javascipt part

try

echo "<a href=\"javascript:;\" onClick=\"window.open('.$file.','resp1','scrollbars=no,width=660,height=505,scrolling=no');\">";
rafazamboni
It did not function...

I discovered that the error occurs due the commas...

<a href="javascript:;" onClick="window.open('.$file.','resp1','scrollbars=no,width=660,height=505,scrolling=no');">


I find that the command in Javascript will not go to function of this form...

It would have some skill to create this code and in the line of link in PHP to place one query to execute the Javascript?

Thank U thnn
BlackSkad
As a matter of fact, it doesn't work due to the single quotes you're using (if I'm not mistaking) Try to escape the single quotes like I did below:
Code:

echo '<a href="" onClick="window.open(\''.$file.'\',\'resp1\',\'scrollbars=no,width=660,height=505,scrolling=no\');" target="_blank"><img src="thumb.php?'.$file.'" alt="'.$alt.'" /></a>'."\n";
?>

Normally, this should help you out...

BlackSkad
rafazamboni
thank BlackSkad....

finally....

it functioned...

thanks thanks thanks
Related topics
Fatal PHP error
Some php probs..need some help plzz!
php error ?[parse error]
suddenly a php error on my website
PHP - Error
PHP Error Pages
[RESOLVED] PHP Error
MySQL/PHP Error..
my first php login w/o database
PHP error
Php error
[help=html,php]Error en forma de contacto...
PHP error page, die()
XML/XHTML header problem
This topic is locked: you cannot edit posts or make replies.    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.