Php Help?

Started on the old forum in September 2006 · view the original in the archive · old links redirect here

16 replies · 1,388 views · started 20 years ago · 1 min read

Guest #1

hey guys, ima php newb here so be kind lol any idea what went wrong here?

basically i just want it to display the different thing for whether the variable .php?type=wml or .php?type=xhtml (carried in the url from the previous page [sorted, no problems with that])

<?php
$xhtml="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE html PUBLIC 
\"-//W3C//DTD XHTML 1.0 Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html>
<head>
<title>test xhtml page</title>
</head>
<body>
<p align=\"center\">
test xhtml page
</p>
</body>
</html>";

$wml="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\"
\"http://www.wapforum.org/DTD/wml_1.1.xml\">
<wml>
<card id=\"c1\" title=\"test wml page\">
<p align=\"center\">
test wml page
</p>
</card>
</wml>";

if($type == xhtml)
  echo $xhtml;
else
  echo $wml;
?>

when i run the xhtml output throuhg the w3c validator, it's okay, but i then get this from the wml output

Result: Failed validation, 0 error

Unknown Parse Mode!

The MIME Media Type (text/html) for this document is used to serve both SGML and XML based documents, and it is not possible to disambiguate it based on the DOCTYPE Declaration in your document. Parsing will continue in SGML mode.

This page is not Valid -//WAPFORUM//DTD WML 1.1//EN! -*-

i've tried a few things, including using this instead

if($type == xhtml)
  echo $xhtml;
elseif($type == wml)
  echo $wml;
else
  {
  $xhtmlredirect = "/index2.php?type=xhtml";
  $wmlredirect = "/index2.php?type=wml";
  if(strpos(strtoupper($HTTP_ACCEPT),"VND.WAP.WML") > 0){
  header("Location: ".$wmlredirect);}
  else{
  header("Location: ".$xhtmlredirect);
  exit;
  }

?>

but it simply gives the error:

Parse error: parse error, unexpected $ in /home/wwwfant/public_html/kwah/index2.php on line 57

any help guys?

Guest #2

oops nvm, i got it working now lol .. i fixed the stoopid noob errors all by myself now lol External image (may be gone):

<?php
if($type == xhtml)
  {
  echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
  echo "<!DOCTYPE html PUBLIC ";
  echo "\"-//W3C//DTD XHTML 1.0 Transitional//EN\"";
  echo "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
  echo "<html>";
  echo "<head>";
  echo "<title>test xhtml page</title>";
  echo "</head>";
  echo "<body><table width=\"100%\" align=\"center\"><tr><td align=\"center\">";
  echo "<img src=\"http://kwah.wen.ru/images/welcome.gif\" alt=\"Welcome to ~* KWAH *~\"/>
";
  echo "</td></tr></table> ";
  echo "<p align=\"center\">";
  echo "[b]~* KWAH *~[/b]
";
  echo "[i]Last Updated: 21/08/2006[/i]
 ";
  echo "
";
  echo "<a href=\"http://kwah.fantasticwap.net/home.php?type=$type\">|[ ENTER ]|</a>
 ";
  echo "xhtml";
  echo "</p>";
  echo "</body>";
  echo "</html>";
  }

elseif($type == wml)
  {
  echo"<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
  echo"<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\"";
  echo"\"http://www.wapforum.org/DTD/wml_1.1.xml\">";
  echo"<wml>";
  echo"<card id=\"c1\" title=\"test wml page\">";
  echo"<p align=\"center\">";
  echo"<img src=\"http://kwah.wen.ru/images/welcome.gif\" alt=\"Welcome to ~* KWAH.wen.ru *~\"/>
";
  echo"[b]~* KWAH.wen.ru *~[/b]
";
  echo"[i]Last Updated: 21/08/2006[/i]
 ";
  echo"
";
  echo"
";
  echo"<a href=\"http://kwah.fantasticwap.net/home.phptype=$type\">|[ ENTER ]|</a>
 ";
  echo"wml";
  echo"</p>";
  echo"</card>";
  echo"</wml>";
  }

else
  {
  $xhtmlredirect = "http://kwah.fantasticwap.net/index2.php?type=xhtml";
  $wmlredirect = "http://kwah.fantasticwap.net/index2.php?type=wml";
  if(strpos(strtoupper($HTTP_ACCEPT),"VND.WAP.WML") > 0){
  header("Location: ".$wmlredirect);}
  else{
  header("Location: ".$xhtmlredirect);}
  }
?>
Guest #3

Oh Thats Grate Bro...u fixed it by ur self....

Guest #4

thanks man .. and yeh, now i need help to 'sqeeze it down' that doesnt invlove having eveything on on line? basically so i dont have to type (or copy,paste External image (may be gone) ) the echo command over and over and over again? it's gonna get kinda difficult later when i get onto the bigger pages if i carry on like i am im experimenting with include() but havn't got very far with that yet .. and it doesn't seem to work if i use it to include a any file other than .php .. any tips?

hmm.. btw gurpreet .. i'm sure i've seen you around before .. ? or at least i recognise that name .. nvm lol

EDIT: btw, im using format this now .. home.php

<?php
$page="home.php";

if($type == xhtml)
  include("xhtml_$page");

elseif($type == wml)
  include("wml_$page");

else
  {
  $xhtmlredirect = "http://kwah.fantasticwap.net/$page?type=xhtml";
  $wmlredirect = "http://kwah.fantasticwap.net/$page?type=wml";
  if(strpos(strtoupper($HTTP_ACCEPT),"VND.WAP.WML") !== true){
  header("Location: ".$xhtmlredirect);}
  else{
  header("Location: ".$wmlredirect);}
  }
?>

and the content of the pages in seperate files .. .. surely there's an easier way? and i don't want to get really into it until i got this bit right cos it would mean i'd hafta spend a LOT of time going through and fixing and debugging it all ..

abhisar #5

you need to type echo if you want to send output.But you can use some php editor.They have option taht if you click on an option echo cames itself.And why do you cut and paste echo,instead just type echo "";

Guest #6

cos i write the page in wml / xhtml first, validate it and check it works, and then put it into php

just thought .. as i posted that last msg -- would this php work?

<?php echo { "<!DOCTYPE ..... <html> <body> simple page </body> </html>" } ?>
abhisar #7

directly write into php.I do this and its easy.And its faster.Opera has inbuilt validator so you dont like anything like w3.org.

And also if you use simple wml and xhtml in php then what is the use of php!!

Guest #8

i want to display two different outputs dependant on what content type the browser accepts .. if i type directly into the php, it doesn't output valid wml/xhtml (W3C validator) ..

and yeh, i use a library computer so i can't download the opera browser

abhisar #9

cos i write the page in wml / xhtml first, validate it and check it works, and then put it into php

just thought .. as i posted that last msg -- would this php work?

<?php echo { "<!DOCTYPE ..... <html> <body> simple page </body> </html>" } ?>

no.But this will work.

<?php
  echo "<!DOCTYPE .....
    <html>
    <body>
    

simple page</p>
    </body>
    </html>";
?>

or this will work

<?php
whatever you want in php
?>
<!DOCTYPE .....
    <html>
    <body>
    

simple page</p>
    </body>
    </html>
Guest #10

bah, why didn't i think of that earlier?? lol

Guest #12

lol, like i said - im a php newb .. but i guess i aint done too badly, considering ..

abhisar #13

Was just joking.Do you need any more help.

Guest #14

lol dnt worri bout it m8 .. still getting a few errors - the MIME type error that i mentioned in the first post (but i think that's to do with the server) and need to sort out my php cos it seems kinda inefficient and awkward to edit ..

abhisar #15

Ya you can improve your php only by practice.Write scripts and sort whatever goes wrong.

Guest #16

yup .. im a fast learner and i think im okay with what i have nowadays lol .. good ol' include() eh? 😂

abhisar #17

???Do you want help with include();

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close