|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
passing variables around several php pages
Hi there,
I have a user authentication set up that then (is supposed) to use the username to provide specific content (in this case a welcome message) per user. The mechanic is you log in, are validated using a mySQL database. You then go to the main page where a message stored as part of your mySQL record is displayed. My problem is that I can't get the record to display. $username is the name of the variable through my pages. I'm using frames. The query code is; PHP Code:
The print_message($username) function is called from this piece of code. PHP Code:
The result of this is that I can't get the message to display. I'm assuming that the problem is to do with passing the $username because when I put a hard coded user name, I get the correct message. thanks in advance for your help, TiaT |
|
#2
|
|||
|
|||
|
Quote:
This is not good coding style. Select * from..... will never guarantee you that some field will appear in the specific posion. An example of better code for your context: <?php mysql_connect($host, $user, $password); mysql_select_db("database"); $result = mysql_query("select user_id, fullname from table"); while ($row = mysql_fetch_array($result)) { echo "user_id: ".$row["user_id"]."<br>\n"; echo "user_id: ".$row[0]."<br>\n"; ..... ..... |
|
#3
|
|||
|
|||
|
thanks Dude, I'll change that query accordingly.
It still doesn't solve my problem though. . ![]() |
|
#4
|
|||
|
|||
|
Looks like you are trying to pass an array to a function that is looking for a string:
PHP Code:
PHP Code:
__________________
__________________________________________________ _ Wil Moore III, MCP | Integrations Specialist | Senior Consultant Are You Listed...? | DigitallySmooth Inc. |
|
#5
|
|||
|
|||
|
yes, I've fixed that so it gives the right record out of the array.
I don't actually get any value or result from the print_r($username[0]) funtion, so I can't post it. ![]() But the problem still remains that I can't get the appropriate value to come up when I use the variable. If I hard code the the username in to the query, I get a result. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > passing variables around several php pages |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|