Jump to content


Photo

need help with parse error


  • Please log in to reply
15 replies to this topic

#1 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 19 July 2006 - 03:39 PM

Here is my echo, but think I don't write it right. hope u can help, thanks.

<?php echo '<img alt="" src="'.$imageArr[$imageShow].'">'."".'<a href='".$imageLink[$imageShow]."'>'; ?>

P.S output:

Parse error: parse error, unexpected '\"', expecting ',' or ';' in /users/3d_cn/html/banner.php on line 44
I don't need your script, I'll try to write it myself

#2 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 19 July 2006 - 03:44 PM

echo "<img alt=\"\" src=\"{$imageArr[$imageshow]}\"> <a href=\"{$imagelink[$imageshow]}\">";

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#3 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 19 July 2006 - 03:47 PM

thanks, I'll try :)
I don't need your script, I'll try to write it myself

#4 SammyP

SammyP
  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts
  • LocationLondon

Posted 19 July 2006 - 03:59 PM

Did that solution work? I can see why yours didn't work in the first place but it is hard to find because of the way you use your quotes.

After your href you drop out of your php string before the double quote goes in. And something similar later on too.

Most importantly, you don't need to drop out of strings to include variables which is what businessman was showing.
His code looks even simpler if you combine your quoting methods so you don't have to escape them:

echo '<img alt="" src="{$imageArr[$imageshow]}"> <a href="{$imagelink[$imageshow]}">';

or

echo "<img alt='' src='{$imageArr[$imageshow]}'> <a href='{$imagelink[$imageshow]}'>";

I'm not even certain you need the curly braces either. They are for more complicated structures, so possibly. But if the array index isn't a variable then you don't, so possibly not. Can't check right now for you. Try it:

echo "<img alt='' src='$imageArr[$imageshow]'> <a href='$imagelink[$imageshow]'>";

Sam.
If this has solved your problem, a quick 'Thanks' is appreciated, but marking the thread as 'Solved' is better - it saves a lot of time.

Sam.

#5 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 20 July 2006 - 08:49 AM

well I've tryed that but it doesn't work....

It displays the picture with red cross and an underscore with link:{$imagelink[$imageshow]} (I see it on the status bar)
I don't need your script, I'll try to write it myself

#6 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 20 July 2006 - 10:14 AM

where are u guys, please help:(
I don't need your script, I'll try to write it myself

#7 GingerRobot

GingerRobot
  • Staff Alumni
  • Advanced Member
  • 4,086 posts
  • LocationUK

Posted 20 July 2006 - 10:24 AM

Try using the last posted by Sam:
<?php
echo "<img alt='' src='$imageArr[$imageshow]'> <a href='$imagelink[$imageshow]'>";
?>

because that should work.

#8 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 20 July 2006 - 10:41 AM

I tryed but it doesn't work, what's my mistake:(

here is the code:

<?php
$imageArr = array();
$imageArr[1] = "http://www.3d.caucas...s/banner1.jpg";
$imageArr[2] = "http://www.3d.caucas...s/banner2.jpg";
$imageArr[3] = "http://www.3d.caucas...s/banner3.jpg";

$imageLink[1] = "http://www.one.com";
$imageLink[2] = "http://www.two.com";
$imageLink[3] = "http://www.three.com";

$imageShow = array_rand($imageArr);
?>

<?php echo "<img alt='' src='$imageArr[$imageshow]'> <a href='$imagelink[$imageshow]'>"; ?>

P.S Here you can see the site, with that error:
http://www.3d.caucasus.net
I don't need your script, I'll try to write it myself

#9 GingerRobot

GingerRobot
  • Staff Alumni
  • Advanced Member
  • 4,086 posts
  • LocationUK

Posted 20 July 2006 - 10:50 AM

The problem is to do with capitalisation. $imageshow is not the same as $imageShow.

change the line to:
<?php echo "<img alt='' src='$imageArr[$imageShow]'> <a href='$imageLink[$imageShow]'>"; ?>

#10 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 20 July 2006 - 10:54 AM

I've done it but the picture is not linked........
I don't need your script, I'll try to write it myself

#11 GingerRobot

GingerRobot
  • Staff Alumni
  • Advanced Member
  • 4,086 posts
  • LocationUK

Posted 20 July 2006 - 10:55 AM

New topic because?

This is your html. You need to nest the image inside of the link tags:
<?php echo "<a href='$imageLink[$imageShow]'><img alt='' src='$imageArr[$imageShow]'></a>";

#12 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 20 July 2006 - 11:00 AM

sorry for the new topic, it's not my fault, I was trying to post and there was an error (I"ll remove this topic)

Here u can see the result, think it's not working correctly, thanks anyway

http://www.3d.caucasus.net
I don't need your script, I'll try to write it myself

#13 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 20 July 2006 - 11:10 AM

Topic has been merged. Please do not post now topics for no reason.

#14 GingerRobot

GingerRobot
  • Staff Alumni
  • Advanced Member
  • 4,086 posts
  • LocationUK

Posted 20 July 2006 - 11:10 AM

Just remove the [/url] part. This forum puts it on after you have a url for some reason.

#15 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 20 July 2006 - 11:14 AM

ok thanks guys, Think I have to work on myself
I don't need your script, I'll try to write it myself

#16 SammyP

SammyP
  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts
  • LocationLondon

Posted 21 July 2006 - 03:14 PM

I assumed you had a </a> somewhere later. Do you?

If this has solved your problem, a quick 'Thanks' is appreciated, but marking the thread as 'Solved' is better - it saves a lot of time.

Sam.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users