|
|||
passing array from mysql to wml using php
<?php
session_start(); include "connect_to_MySQL.php"; ?> <?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" "http://www.wapforum.org/DTD/wml13.dtd"> <wml> <card id="myprofile" title="My Profile"> <p>This is your profile. </p> <?php $query = "SELECT * FROM ownerdetails WHERE Login_id = '" . $_SESSION['user_logged'] . "' "; $result = mysql_query($query) or die(mysql_error()); while ($row=mysql_fetch_array($result)) { $Name=$row['Name']; ?> <p> Full Name : <?php echo $Name; ?> <?php } ?> </card> </wml> Is this the correct command to do it? I tried to open it in emulator but the data suppose to import from mysql didn't show up. The only think whish show up is <p>This is your profile. </p> I tried to use the php command in html, it works fine. regards Areah |
|
|||
Maybe you can try to use nokia s60 simulator. It works fine with me. You can download it in nokia forum. It is free.
Is it wml can not accept session command which embedded to the php? It is because when user log in, i store the login ID ad password in session command. Hence i can recall it in another script to work on it. But it seems, it didn't store the data. In the login.php, i have something: session_start(); $_SESSION['user_logged']=$mylogin_id; $_SESSION['password_logged']=$password; And in myprofile.php, i recall the session to retrieve data from mysql. session_start(); $query = "SELECT * FROM ownerdetails WHERE Login_id = '" . $_SESSION['user_logged'] . "' "; $result = mysql_query($query) or die(mysql_error()); It showed nothing. Hence, i tried to echo $_SESSION['user_logged']. It didn't shows any data. |
|
|||
And one more thing, the unclosed <p> element has nothing to do with the error. I tried to manually key in the login ID in the command, it shows my name.
$query = "SELECT * FROM ownerdetails WHERE Login_id = '" . 123 . "' "; $result = mysql_query($query) or die(mysql_error()); I conclude, it is because the passing array using session. That is why i asked about the session command. |
|
||||
If you suspect the $_SESSION array, try a single file test like
Code:
<?php session_start(); /* your database connect and select code */ $query = "SELECT * FROM ownerdetails WHERE Login_id = '" . $_SESSION["mykey"] . "' "; $result = mysql_fetch_array(mysql_query($query)) or die(mysql_error()); echo print_r($result, true); $_SESSION["mykey"] = 123; ?> |
|
|||
If i use the method you mentioned which i have tried, it works fine.
But, the problem with the session is that the session doesn't store the data which i have identified in the first script then i want to import it in the second script. If the storing of the data in session is put in the same script while you you use it, it works fine. If put it in different script then the session can't pass the data. |
|
||||
If the single file version works, then the session is working. Try this 2 file version:
file1.php: Code:
<?php session_start(); $_SESSION["mykey"] = 123; ?> Code:
<?php session_start(); /* your database connect and select code */ $query = "SELECT * FROM ownerdetails WHERE Login_id = '" . $_SESSION["mykey"] . "' "; $result = mysql_fetch_array(mysql_query($query)) or die(mysql_error()); echo print_r($result, true); ?> If you get nothing at all... we'll have to think of something else! --edit-- Admins! Shouldn't this thread be in the "Website Programming" forum? Last edited by Seanie; 29-08-2008 at 11:08 PM. Reason: Admin attention? |
|
|||
It can not be done either..
Still blank page. It only can work if i staright away put in the key.Something like: <?php session_start(); /* your database connect and select code */ $query = "SELECT * FROM ownerdetails WHERE Login_id = '" . 123 . "' "; $result = mysql_fetch_array(mysql_query($query)) or die(mysql_error()); echo print_r($result, true); ?> |
|
||||
Quote:
Here's the simplest 2-file test I can think of: file1.php: Code:
<?php session_start(); $_SESSION["mykey"] = 123; ?> Code:
<?php session_start(); echo print_r($_SESSION, true); ?> Have you looked in apache's error_log? |
|
|||
|
|
|
|||
I test it with emulator i mentioned earlier.
Maybe you can try to download and take a look. It is nokia s60 emulator. Quote:
<anchor> <go method="post" href="test2.php"> <postfield name="user" value="$(myloginid)"/> <postfield name="pass" value="$(mypassword)"/> </go> Submit </anchor> </p> In my test2.php, i start the session: session_start(); $_SESSION['user_logged']=$mylogin_id; $_SESSION['password_logged']=$password; the value of $mylogin_id comes from the submission from test1.php which is <postfield name="user" value="$(myloginid)"/> After i started the session, is used the session: <?php echo "Thank you for logging in, "; $Name="SELECT Name FROM ownerdetails WHERE Login_id='" . $_SESSION['user_logged'] . "'"; $result=mysql_query($Name) or die(mysql_error()); while ($row=mysql_fetch_assoc($result)) { extract($row); echo $Name; echo "<br>"; } ?> In here, the session works fine. It can retrive the data from mysql. Afterward, in test3.php, i use the same method to retrieve the data which is : session_start(); $query = "SELECT * FROM ownerdetails WHERE Login_id = '" . $_SESSION['user_logged'] . "' "; $result = mysql_query($query) or die(mysql_error()); while ($row=mysql_fetch_array($result)) { $Name=$row['Name']; } But, it showed nothing. This is what i mean. Both of the coding use session to retrieve the data. And where can i find apache's error_log? Thanks! |
|
||||
Quote:
![]() Did you try the simple two-file example from my previous post? Your problem could be with a typo in your database code or even your HTML output. If you believe it's a session problem, delete everything except the session code that you think is not working properly. Or better still, just use the code I posted. If my code works, your problem isn't with sessions. In test3.php - no HTML output, how could you see anything? Code:
{
$Name=$row['Name'];
}
Quote:
|
|
|||
Oops..sorry in the last reply i forget to paste out that to show the data i have this code.
<p> Full Name : <?php echo $Name; ?> I just said if you want then you can take a look at the simulator because you mentioned earlier that you interested to do some WML development yourself. ![]() That's all. If i do it without session. Something like your code: Quote:
They work fine. I found folder call "error" under apache. But can't really find the 'error log". I will go through all the files in the error folder one by one to see if i can find anything. |
|
||||
Try echoing, copying and pasting your $query variable into whatever you use to do admin on your MySQL database. Just echoing it might show you where you're going wrong. If the problem is a bit harder to spot, pasting the statement into phpMyAdmin or whatever you're using will reveal any errors if that's what's giving you trouble.
I notice you're building up your queries by concatenating strings. I've just gone through a couple of Java applications converting all the joined string SQL statements to PreparedStatements. It might be worth your while checking out the mysqli interface in PHP: PHP: Prepared statements and stored procedures - Manual |
![]() |
«
Previous Thread
|
Next Thread
»
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| please help...shopping cart passing values to another page | angie_wnv | Website Programming | 0 | 08-03-2007 05:53 PM |
| passing value | nov8998 | Website Programming | 4 | 18-08-2004 11:15 AM |
| mcm mane nak insert array dalm database | kasih | Website Programming | 7 | 24-09-2002 12:07 PM |
| error jika x masukkan value tuk array | kasih | Website Programming | 16 | 24-09-2002 10:06 AM |
| array sorting | joyce | Website Programming | 2 | 16-06-2002 01:26 AM |
All times are GMT +8. The time now is 07:43 PM.
Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0 vBulletin skin by
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0 vBulletin skin by













Linear Mode

