943,949 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 4382
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Mar 29th, 2008
0

Login session

Expand Post »
Hello does anyone know how to bring details from a database into a textbox? becuase ive got the login working and it displays whos logged in but i want the postcode to appear in a textbox, the postcode is kept in mysql table called address.

/after connecting to mysql
php Syntax (Toggle Plain Text)
  1. $query = "SELECT * FROM StudentRecords WHERE Email= '".$myusername."'";
  2. $result = mysql_query($query);
  3.  
  4. <td><input type="text" name="PickupAddressPostCode"</td>
Last edited by peter_budo; Mar 30th, 2008 at 6:19 am. Reason: Keep It Organized - please use [code] tags
Similar Threads
Reputation Points: 10
Solved Threads: 3
Junior Poster in Training
sukhy_1 is offline Offline
63 posts
since Mar 2008
Mar 29th, 2008
0

Re: Login session

PHP Syntax (Toggle Plain Text)
  1. $query = "SELECT address_code FROM address WHERE userID= '".$myuserID."'";
  2. $result = mysql_query($query);
  3.  
  4. <td><input type="text" name="PickupAddressPostCode" value="<?php echo $result['address_code']; ?>" /></td>


Matti Ressler
Suomedia
Last edited by Suomedia; Mar 29th, 2008 at 12:24 pm.
Reputation Points: 15
Solved Threads: 19
Junior Poster
Suomedia is offline Offline
154 posts
since Mar 2008
Mar 29th, 2008
0

Re: Login session

thank u
Reputation Points: 10
Solved Threads: 3
Junior Poster in Training
sukhy_1 is offline Offline
63 posts
since Mar 2008
Mar 29th, 2008
0

Re: Login session

Mark as solved
Reputation Points: 15
Solved Threads: 19
Junior Poster
Suomedia is offline Offline
154 posts
since Mar 2008
Mar 29th, 2008
0

Re: Login session

Its meant to select the postcode from the address table where the email matchs the login name which is myusername. and then display postcode in the textbox. it connects to database but in the textbox what the postcode is meant to appear in it says...
<br /><b>Notice</b>: Undefined variable: result in <b>/home/public_html/book.php</b> on line <b>79</b><br />


php Syntax (Toggle Plain Text)
  1. <?
  2. $query = "SELECT PostCode FROM address WHERE
  3. Email= '".$myusername."'";
  4. $result = mysql_query($query);
  5. ?>
  6.  
  7. line 79 is here
  8. <td><input type="text" name="PickPostCode" value="<?php echo
  9. $result['PostCode ']; ?>" /></td>
Last edited by peter_budo; Mar 30th, 2008 at 6:19 am. Reason: Keep It Organized - please use [code] tags
Reputation Points: 10
Solved Threads: 3
Junior Poster in Training
sukhy_1 is offline Offline
63 posts
since Mar 2008
Mar 29th, 2008
0

Re: Login session

You need to connect to mySQL, select the database, make the query, fetch the result with mysql_fetch_array() and close the connection.


Matti Ressler
Suomedia
Reputation Points: 15
Solved Threads: 19
Junior Poster
Suomedia is offline Offline
154 posts
since Mar 2008
Mar 29th, 2008
0

Re: Login session

ive got the connection the database connection and everything working expect that 1 notice
Reputation Points: 10
Solved Threads: 3
Junior Poster in Training
sukhy_1 is offline Offline
63 posts
since Mar 2008
Mar 29th, 2008
0

Re: Login session

Click to Expand / Collapse  Quote originally posted by Suomedia ...
PHP Syntax (Toggle Plain Text)
  1. $query = "SELECT address_code FROM address WHERE userID= '".$myuserID."'";
  2. $result = mysql_query($query);
  3.  
  4. <td><input type="text" name="PickupAddressPostCode" value="<?php echo $result['address_code']; ?>" /></td>


Matti Ressler
Suomedia

That should actually be
php Syntax (Toggle Plain Text)
  1. $query = "SELECT address_code FROM address WHERE userID= '".$myuserID."'";
  2. $result = mysql_query($query);
  3. $row = mysql_fech_array($result); //or while($row = mysql_fetch_array($result)) if your query returns more than 1 row
  4. <td><input type="text" name="PickupAddressPostCode" value="<?php echo $row['address_code']; ?>" /></td>

Cheers,
Naveen
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
Mar 30th, 2008
0

Re: Login session

Still not working
Reputation Points: 10
Solved Threads: 3
Junior Poster in Training
sukhy_1 is offline Offline
63 posts
since Mar 2008
Mar 30th, 2008
0

Re: Login session

Same error ? Try mysql_error() with die statement. Also print out your query and tell us what it says !
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Prase error..Pls help.. simple script..
Next Thread in PHP Forum Timeline: Updating Profile





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC