Php Help?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Php Help?

    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])

    Code:
    <?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&#39;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![/b]
    -*-

    i&#39;ve tried a few things, including using this instead

    Code:
    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[/b]
    any help guys?

  • #2
    oops nvm, i got it working now lol .. i fixed the stoopid noob errors all by myself now lol :

    Code:
    <?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 "~* KWAH *~
    ";
      echo "Last Updated: 21/08/2006
     ";
      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"~* KWAH.wen.ru *~
    ";
      echo"Last Updated: 21/08/2006
     ";
      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);}
      }
    ?>

    Comment


    • #3
      Oh Thats Grate Bro...u fixed it by ur self....

      Comment


      • #4
        thanks man .. and yeh, now i need help to &#39;sqeeze it down&#39; that doesnt invlove having eveything on on line?
        basically so i dont have to type (or copy,paste ) the echo command over and over and over again? it&#39;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&#39;t got very far with that yet .. and it doesn&#39;t seem to work if i use it to include a any file other than .php .. any tips?

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


        EDIT: btw, im using format this now ..
        home.php
        Code:
        <?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&#39;s an easier way? and i don&#39;t want to get really into it until i got this bit right cos it would mean i&#39;d hafta spend a LOT of time going through and fixing and debugging it all ..

        Comment


        • #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 "";

          Comment


          • #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</p>
            </body>
            </html>"
            }
            ?>

            Comment


            • #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!!

              Comment


              • #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&#39;t output valid wml/xhtml (W3C validator) ..

                and yeh, i use a library computer so i can&#39;t download the opera browser

                Comment


                • #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</p>
                  </body>
                  </html>"
                  }
                  ?>[/b]
                  no.But this will work.
                  Code:
                  <?php
                    echo "<!DOCTYPE .....
                      <html>
                      <body>
                      
                  
                  simple page</p>
                      </body>
                      </html>";
                  ?>
                  or this will work

                  Code:
                  <?php
                  whatever you want in php
                  ?>
                  <!DOCTYPE .....
                      <html>
                      <body>
                      
                  
                  simple page</p>
                      </body>
                      </html>

                  Comment


                  • #10
                    bah, why didn&#39;t i think of that earlier?? lol

                    Comment


                    • #11
                      Think a bit

                      Comment


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

                        Comment


                        • #13
                          Was just joking.Do you need any more help.

                          Comment


                          • #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&#39;s to do with the server) and need to sort out my php cos it seems kinda inefficient and awkward to edit ..

                            Comment


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

                              Comment

                              Working...
                              X