codygoodman Posted August 14, 2007 Share Posted August 14, 2007 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 More sharing options...
lemmin Posted August 14, 2007 Share Posted August 14, 2007 I think you are looking for $_SERVER['REQUEST_URI'] instead of: $REQUEST_URI and this line: "$f $l": Just doesn't make sense. Link to comment https://forums.phpfreaks.com/topic/64940-solved-new-to-php-simple-script-help/#findComment-324053 Share on other sites More sharing options...
codygoodman Posted August 14, 2007 Author Share Posted August 14, 2007 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. Link to comment https://forums.phpfreaks.com/topic/64940-solved-new-to-php-simple-script-help/#findComment-324086 Share on other sites More sharing options...
lemmin Posted August 14, 2007 Share Posted August 14, 2007 This line: "$f $l": It just isn't a statement. I don't know what you are trying to do with it, but if you remove it, your code might work. Link to comment https://forums.phpfreaks.com/topic/64940-solved-new-to-php-simple-script-help/#findComment-324091 Share on other sites More sharing options...
codygoodman Posted August 14, 2007 Author Share Posted August 14, 2007 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> Link to comment https://forums.phpfreaks.com/topic/64940-solved-new-to-php-simple-script-help/#findComment-324092 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.