php with wml

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • binukjames
    New Member
    • Mar 2008
    • 6

    php with wml

    I'm developing a wap site with wml and php.
    my php code is retrievig and displaying blob image from database.
    but i cannot include any wml part to this page.
    actually i want to display image from database with some links.
    is it possible ? plz help me....

    my php code is....
    [code=php]
    <?php
    function db_connect($use r='root', $password='admi n', $db='example')
    {
    mysql_connect(' localhost', $user, $password) or die('I cannot connect to db: ' . mysql_error());
    mysql_select_db ('example');
    }
    db_connect();
    $sql = "select imgdata from pix where title=2";


    $result = mysql_query("$s ql");
    while($row = mysql_fetch_ass oc($result))
    {
    $bytes = $row['imgdata'];
    }
    header("Content-type: image/jpeg");
    echo $bytes;
    exit ();
    mysql_close();
    ?>
    [/code]
    Last edited by Atli; Jul 4 '08, 05:24 PM. Reason: Added [code] tags and removed unnecessary bold text.
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Is is possible - everything is possible with PHP; even interstellar domination!

    I have no idea what WML is - wireless markup language?

    Actually, re-looking at your code, you display an image page.. not a html/whateverelse type. The only way you can put text onto this page is if make a html page and echo the image onto it.

    Comment

    • binukjames
      New Member
      • Mar 2008
      • 6

      #3
      thanks 4 replay.
      but if i give one single echo ( eg : echo"hellow world";)
      before header("Content-type: image/jpeg");
      i m getting the following output...
      -----------------------------------------------------------------------------------------------------
      hellow world

      Warning: Cannot modify header information - headers already sent by
      (output started at C:\web\htdocs\s how\image.php:7 ) in C:\web\htdocs\s how\image.php on line 15

      ÿØÿàJFIF``ÿá ExifMM*bj(1r 2އi¤Ð¦'
      H¼—«ÿ?îÛ„ætºD ûiÇ?cùÛòÿæöý: +¡tÿ㇦fäâàg... ..
      ----------------------------------------------------------------------------------------------------------

      actually my requrement to display image from database with some links.(its a wap site)

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Originally posted by binukjames
        thanks 4 replay.
        but if i give one single echo ( eg : echo"hellow world";)
        before header("Content-type: image/jpeg");
        i m getting the following output...
        -----------------------------------------------------------------------------------------------------
        hellow world

        Warning: Cannot modify header information - headers already sent by
        (output started at C:\web\htdocs\s how\image.php:7 ) in C:\web\htdocs\s how\image.php on line 15

        ÿØÿàJFIF``ÿá ExifMM*bj(1r 2އi¤Ð¦'
        H¼—«ÿ?îÛ„ætºD ûiÇ?cùÛòÿæöý: +¡tÿ㇦fäâàg... ..
        ----------------------------------------------------------------------------------------------------------

        actually my requrement to display image from database with some links.(its a wap site)
        Like I said: you cannot echo anything apart from image data because this is an image data page.

        Comment

        • binukjames
          New Member
          • Mar 2008
          • 6

          #5
          actually i want to display an image from database with a link to another php file.

          how can i do this ?
          can u tell me any idea ? / (any sample code ?)
          Last edited by Atli; Jul 4 '08, 05:25 PM. Reason: removed unnecessary bold text. Please don't post your entire message in bold!

          Comment

          • Markus
            Recognized Expert Expert
            • Jun 2007
            • 6092

            #6
            Originally posted by binukjames
            actually i want to display an image from database with a link to another php file.

            how can i do this ?
            can u tell me any idea ? / (any sample code ?)
            Something like this (you'll have to fill in the variables yourself):

            html page -
            Code:
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
            <head>
            </head>
            
            <body>
            
            <a href="img.php?id=some_id" />
                <img src="img.php?id=some_id" />
            </a>
            
            </body>
            img.php -
            Code:
            $id = $_GET['id']; #escape this
            
            function db_connect($user='root', $password='admin', $db='example')
            {
            mysql_connect('localhost', $user, $password) or die('I cannot connect to db: ' . mysql_error());
            mysql_select_db('example');
            } 
            db_connect(); 
            $sql = "select imgdata from pix where title='{$id}'";
            
            
            $result = mysql_query($sql); 
            while($row = mysql_fetch_assoc($result))
            { 
            $bytes = $row['imgdata'];
            } 
            header("Content-type: image/jpeg");
            echo $bytes;
            exit (); 
            mysql_close();
            This is just an example.

            Comment

            • binukjames
              New Member
              • Mar 2008
              • 6

              #7
              ok. i tried this , when i click the link its displaying image .
              but there is no " link " in the image page....(image is displaying without any link)
              then how can i go to next page after displaying the image ?

              Comment

              • Markus
                Recognized Expert Expert
                • Jun 2007
                • 6092

                #8
                Originally posted by binukjames
                ok. i tried this , when i click the link its displaying image .
                but there is no " link " in the image page....(image is displaying without any link)
                then how can i go to next page after displaying the image ?
                OK.

                Have a page, img.php, that does all the pulling of the image data.

                Then have another page, display.php, that is dynamic. By that I mean, the page is passed a parameter through the URL - display.php?id= some_id
                You then use this id and pass it to img.php so it can output the image. You would then create a link that gets the next image id - display.php?id= another_id

                Comment

                • binukjames
                  New Member
                  • Mar 2008
                  • 6

                  #9
                  its working....
                  Thank u very much...

                  Comment

                  Working...