Jump to content

[SOLVED] New to php... simple script help


codygoodman

Recommended Posts

Hey not quite sure what the error in my syntax is:

 

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-

 

transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

 

<?php

$myvars = explode("/",$REQUEST_URI);

for ($i=0;$i<count($myvars);$i++) {

$holder = explode("=",$myvars[$i]);

${$holder[0]} = $holder[1];

}

?>

</head>

 

<body>

 

Hey <?php

"$f $l":

if ($f == "") { $f = "Friend"; }

echo "$f $l";

?>

 

 

</body>

</html>

 

 

Just a simple script to insert a name that works fine, except the part to make the default "friend".

 

 

Thanks, Cody

Link to comment
https://forums.phpfreaks.com/topic/64940-solved-new-to-php-simple-script-help/
Share on other sites

ok forgot to add... i use a special url such as:

 

http://businesstips101.com/phpfun/sales.php/f=Your/l=Name

 

 

to enter the name in...

 

It says the problem is on line 19

 

the script worked fine until I tried to enter:

 

if ($f == "") { $f = "Friend"; }

 

 

so that it would say "hello friend" if they just went to the sales.php page.

Ok I got it fixed....

 

I used a : rather than a ;

 

Here's the working script, as long as you use a url such as http://businesstips101.com/phpfun/sales.php/f=cody/l=goodman.

 

I just used the special url to insert the value into the variable. Thats what the $l and $f are for :)

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-

 

transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

 

<?php

$myvars = explode("/",$REQUEST_URI);

for ($i=0;$i<count($myvars);$i++) {

$holder = explode("=",$myvars[$i]);

${$holder[0]} = $holder[1];

}

?>

</head>

 

<body>

 

Hey <?php

"$f $l";

if ($f == "") { $f = "Friend"; }

 

?>

<?php

echo "$f $l"; ?>

 

 

</body>

</html>

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.