This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-02-02 05:02:01

Magmawulf
New Scratcher
Registered: 2012-01-14
Posts: 80

TroubleShooting [PHP] [HTML] [Links]

Hi, I need to work out the problem with this script, please help me:

Code:

<html>
<head>Adfly Links</head>
<body>
<?php
$x = 0
$x= $x + 1
echo "<a href=\$x . ".html">Follow Me</a>";
?>
<a href="\"<?php echo $x ; ?>".html"><?php echo $x; ?></a><br>
<? php $x = $x + 1; ?>
<a href="\<?php echo $x; ?> .html"><?php echo $x; ?></a><br>
<? php $x = $x + 1; ?>
<a href="\<?php echo $x; ?> .html"><?php echo $x; ?></a><br>
<? php $x = $x + 1; ?>
<a href="\<?php echo $x; ?> .html"><?php echo $x; ?></a><br>
<? php $x = $x + 1; ?>

</body>
</html>

(It's a project I'm working on in free time)

Offline

 

#2 2012-02-02 05:15:19

trinary
Scratcher
Registered: 2012-01-29
Posts: 1000+

Re: TroubleShooting [PHP] [HTML] [Links]

What is it supposed to do?


http://trinary.tk/images/signature_.php

Offline

 

#3 2012-02-02 05:18:29

Magmawulf
New Scratcher
Registered: 2012-01-14
Posts: 80

Re: TroubleShooting [PHP] [HTML] [Links]

trinary wrote:

What is it supposed to do?

Set a html link to  (variable X) . html

So it would look like
<a href="/1.html">1</a>
<a href="/2.html">2</a>

Without me having to right every single link in.  wink

Offline

 

#4 2012-02-02 05:27:07

trinary
Scratcher
Registered: 2012-01-29
Posts: 1000+

Re: TroubleShooting [PHP] [HTML] [Links]

You forgot the ; on lines 4 and 5
$x is not global?
Try adding a space after the \ when you use $x (otherwise it escapes it?)
Try removing the extra " on line 9


http://trinary.tk/images/signature_.php

Offline

 

#5 2012-02-02 05:31:13

trinary
Scratcher
Registered: 2012-01-29
Posts: 1000+

Re: TroubleShooting [PHP] [HTML] [Links]

I mean, lines 5 and 6 (for the first suggestion)  tongue


http://trinary.tk/images/signature_.php

Offline

 

#6 2012-02-02 05:33:18

Magmawulf
New Scratcher
Registered: 2012-01-14
Posts: 80

Re: TroubleShooting [PHP] [HTML] [Links]

New code:

Code:

<html>
<head></head>
<body>
<?php
$_SESSION['x'] = '0';
$_SESSION['x'] = 'x + 1';
?>
<a href="\ <?php echo $SESSION['x'] ; ?>.html"><?php echo $x; ?></a><br>
<? php $x = $x + 1; ?>
<a href="\<?php echo $x; ?>.html"><?php     echo $x; ?></a><br>

</body>
</html>

Offline

 

#7 2012-02-02 05:46:18

trinary
Scratcher
Registered: 2012-01-29
Posts: 1000+

Re: TroubleShooting [PHP] [HTML] [Links]

Although if you had a lot of such links, you would be advised to make a function.


http://trinary.tk/images/signature_.php

Offline

 

#8 2012-02-02 07:39:54

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: TroubleShooting [PHP] [HTML] [Links]

Like this?

Code:

<html>
<head></head>
<body>
<?php
$x = 0;
$x++;
?>
<a href="<?php echo $x; ?>.html"><?php echo $x; ?></a><br>
<?php $x = $x + 1; ?>
<a href="<?php echo $x; ?>.html"><?php echo $x; ?></a><br>

</body>
</html>

Offline

 

#9 2012-02-02 10:54:46

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: TroubleShooting [PHP] [HTML] [Links]

Code:

<?php
$x = 0;
$page = '<html>
<head><title>Adfly Links</title></head>
<body>';
while ($x < 3) {
    $page .= '<a href="'.$x.'.html">'.$x.'</a><br />';
    $x++;
}
$page .= '</body>
</html>';
echo $page;
?>

I really dislike switching between PHP and HTML like what you've done. ( <html><?php ?></html> ) It's really messy.

Offline

 

#10 2012-02-02 11:02:33

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: TroubleShooting [PHP] [HTML] [Links]

Magnie wrote:

Code:

<?php
$x = 0;
$page = '<html>
<head><title>Adfly Links</title></head>
<body>';
while ($x < 3) {
    $page .= '<a href="'.$x.'.html">'.$x.'</a><br />';
    $x++;
}
$page .= '</body>
</html>';
echo $page;
?>

I really dislike switching between PHP and HTML like what you've done. ( <html><?php ?></html> ) It's really messy.

I think it's fine like that. As Sparks said, it gives syntax highlighting.  tongue

Offline

 

#11 2012-02-02 11:04:19

Daffy22
Scratcher
Registered: 2008-12-15
Posts: 500+

Re: TroubleShooting [PHP] [HTML] [Links]

Magnie wrote:

Code:

<?php
$x = 0;
$page = '<html>
<head><title>Adfly Links</title></head>
<body>';
while ($x < 3) {
    $page .= '<a href="'.$x.'.html">'.$x.'</a><br />';
    $x++;
}
$page .= '</body>
</html>';
echo $page;
?>

I really dislike switching between PHP and HTML like what you've done. ( <html><?php ?></html> ) It's really messy.

I prefer to switch between html and php because you can code html as normal without worrying about double quotes and stuff.  smile


http://img201.imageshack.us/img201/1784/logosmalle.png
"Spectacular - 5 Star" -  CNET.com Editor.

Offline

 

#12 2012-02-02 11:12:24

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: TroubleShooting [PHP] [HTML] [Links]

Daffy&Sci: Well, it's hard to read the PHP then. Which could result in errors.

Offline

 

#13 2012-02-02 11:32:21

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: TroubleShooting [PHP] [HTML] [Links]

Magnie wrote:

Daffy&Sci: Well, it's hard to read the PHP then. Which could result in errors.

Well, each to his own.  smile

Offline

 

#14 2012-02-02 14:21:32

Magmawulf
New Scratcher
Registered: 2012-01-14
Posts: 80

Re: TroubleShooting [PHP] [HTML] [Links]

Magnie wrote:

Code:

<?php
$x = 0;
$page = '<html>
<head><title>Adfly Links</title></head>
<body>';
while ($x < 3) {
    $page .= '<a href="'.$x.'.html">'.$x.'</a><br />';
    $x++;
}
$page .= '</body>
</html>';
echo $page;
?>

I really dislike switching between PHP and HTML like what you've done. ( <html><?php ?></html> ) It's really messy.

Thank you - this is what I was looking for.  smile

Offline

 

Board footer