Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
anyone help with this code pls!
Old 09-11-2007, 02:13 PM anyone help with this code pls!
Experienced Talker

Posts: 37
Trades: 0
is there something wrong in this code? im trying to put that on my index.php but it doesnt work and the error is in this lines, any1 has any idea?

echo '<center>
<script language='javascript' type='text/javascript'>
<!--var
thePics = new Array()

thePics[1] = 'http://clan-d2k.net/siteimages/images/random/1.jpg'
thePics[2] = 'http://clan-d2k.net/siteimages/images/random/2.jpg'
thePics[3] = 'http://clan-d2k.net/siteimages/images/random/3.jpg'
thePics[4] = 'http://clan-d2k.net/siteimages/images/random/4.jpg'
thePics[5] = 'http://clan-d2k.net/siteimages/images/random/5.jpg'
thePics[6] = 'http://clan-d2k.net/siteimages/images/random/6.jpg'
thePics[7] = 'http://clan-d2k.net/siteimages/images/random/7.jpg'
thePics[8] = 'http://clan-d2k.net/siteimages/images/random/8.jpg'
thePics[9] = 'http://clan-d2k.net/siteimages/images/random/9.jpg'
thePics[10] = 'http://clan-d2k.net/siteimages/images/random/10.jpg'
thePics[11] = 'http://clan-d2k.net/siteimages/images/random/11.jpg'
thePics[12] = 'http://clan-d2k.net/siteimages/images/random/12.jpg'

var rn = Math.floor(Math.random() * thePics.length)
if (rn == 0)
{rn = 1}


document.write('<img src= '+thePics[rn]+' border="0">')
//-->

</script>
</center>';


Thank you so much.
vanhell06 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-11-2007, 02:22 PM Re: anyone help with this code pls!
Skilled Talker

Posts: 62
Name: Tom Wright
Location: Brighton, UK
Trades: 0
OK, what you've forgotten to do is escape the single quote marks you use in your javascript. Put another way you've got end quotes inside your echo statement that make the php interpreter very confused when it encouters more text after them.
Simply replace each ' with a \' inside whatever you're echoing.
echo 'thePics[10] = 'http://clan-d2k.net/siteimages/images/random/10.jpg'';
would become:
echo 'thePics[10] = \'http://clan-d2k.net/siteimages/images/random/10.jpg\'';
Got it?
__________________
My site:
Please login or register to view this content. Registration is FREE
tomythius is offline
Reply With Quote
View Public Profile
 
Old 09-11-2007, 02:25 PM Re: anyone help with this code pls!
Super Talker

Posts: 134
Trades: 0
your echo stops here 'javascript

2 solutions : or you start with echo "<center>
and end with </center>";

or you make it 100 % html: leave echo ' at the top
and the '; and the end
__________________

Please login or register to view this content. Registration is FREE

Check out the Facebook Clone build with Jcow SNS at
Please login or register to view this content. Registration is FREE
, it is free and it always will be
Falcone is offline
Reply With Quote
View Public Profile
 
Old 09-11-2007, 08:13 PM Re: anyone help with this code pls!
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
OR just clsoe your PHP brackets before this and reopen them after...

so like
Some PHP
?>
all your javascriipt stuff you are echoing
<?php
more PHP

much easier sometimes and saves adding a ton mor Chars to your files,

Also the <center> tag has depreiciated so you are better using something like <div> and using CSS to center..

Dan
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Reply     « Reply to anyone help with this code pls!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13577 seconds with 12 queries