473,406 Members | 2,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

php with wml

binukjames
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....
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. function db_connect($user='root', $password='admin', $db='example')
  3.     {
  4.     mysql_connect('localhost', $user, $password) or die('I cannot connect to db: ' . mysql_error());
  5.     mysql_select_db('example'); 
  6.     }                                
  7.         db_connect();        
  8.         $sql = "select imgdata from pix where title=2";
  9.  
  10.  
  11.         $result = mysql_query("$sql");        
  12.         while($row = mysql_fetch_assoc($result))
  13.             {           
  14.                                         $bytes = $row['imgdata'];
  15.              }    
  16.         header("Content-type: image/jpeg");
  17.                               echo $bytes;
  18.                   exit ();                
  19.                  mysql_close();    
  20.               ?>
  21.  
Jun 26 '08 #1
8 1538
Markus
6,050 Expert 4TB
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.
Jun 26 '08 #2
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\show\image.php:7) in C:\web\htdocs\show\image.php on line 15

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

actually my requrement to display image from database with some links.(its a wap site)
Jun 26 '08 #3
Markus
6,050 Expert 4TB
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\show\image.php:7) in C:\web\htdocs\show\image.php on line 15

ÿØÿàJFIF``ÿá ExifMM*bj(1r2Ž‡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.
Jun 26 '08 #4
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 ?)
Jun 26 '08 #5
Markus
6,050 Expert 4TB
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 -
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  3. <head>
  4. </head>
  5.  
  6. <body>
  7.  
  8. <a href="img.php?id=some_id" />
  9.     <img src="img.php?id=some_id" />
  10. </a>
  11.  
  12. </body>
  13.  
img.php -
Expand|Select|Wrap|Line Numbers
  1. $id = $_GET['id']; #escape this
  2.  
  3. function db_connect($user='root', $password='admin', $db='example')
  4. {
  5. mysql_connect('localhost', $user, $password) or die('I cannot connect to db: ' . mysql_error());
  6. mysql_select_db('example');
  7. db_connect(); 
  8. $sql = "select imgdata from pix where title='{$id}'";
  9.  
  10.  
  11. $result = mysql_query($sql); 
  12. while($row = mysql_fetch_assoc($result))
  13. $bytes = $row['imgdata'];
  14. header("Content-type: image/jpeg");
  15. echo $bytes;
  16. exit (); 
  17. mysql_close();
  18.  
This is just an example.
Jun 26 '08 #6
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 ?
Jun 26 '08 #7
Markus
6,050 Expert 4TB
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
Jun 26 '08 #8
its working....
Thank u very much...
Jun 26 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: William C. White | last post by:
Does anyone know of a way to use PHP /w Authorize.net AIM without using cURL? Our website is hosted on a shared drive and the webhost company doesn't installed additional software (such as cURL)...
2
by: Albert Ahtenberg | last post by:
Hello, I don't know if it is only me but I was sure that header("Location:url") redirects the browser instantly to URL, or at least stops the execution of the code. But appearantely it continues...
3
by: James | last post by:
Hi, I have a form with 2 fields. 'A' 'B' The user completes one of the fields and the form is submitted. On the results page I want to run a query, but this will change subject to which...
0
by: Ollivier Robert | last post by:
Hello, I'm trying to link PHP with Oracle 9.2.0/OCI8 with gcc 3.2.3 on a Solaris9 system. The link succeeds but everytime I try to run php, I get a SEGV from inside the libcnltsh.so library. ...
1
by: Richard Galli | last post by:
I want viewers to compare state laws on a single subject. Imagine a three-column table with a drop-down box on the top. A viewer selects a state from the list, and that state's text fills the...
4
by: Albert Ahtenberg | last post by:
Hello, I have two questions. 1. When the user presses the back button and returns to a form he filled the form is reseted. How do I leave there the values he inserted? 2. When the...
1
by: inderjit S Gabrie | last post by:
Hi all Here is the scenerio ...is it possibly to do this... i am getting valid course dates output on to a web which i have designed ....all is okay so far , look at the following web url ...
2
by: Jack | last post by:
Hi All, What is the PHP equivilent of Oracle bind variables in a SQL statement, e.g. select x from y where z=:parameter Which in asp/jsp would be followed by some statements to bind a value...
3
by: Sandwick | last post by:
I am trying to change the size of a drawing so they are all 3x3. the script below is what i was trying to use to cut it in half ... I get errors. I can display the normal picture but not the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.