942,959 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 36
  • PHP RSS
Jul 30th, 2010
0

setting the value in my

Expand Post »
can some tell me what's wrong i tried putting the $date in my textfield from my MySQL. can someone pls correct my code thanks

PHP Syntax (Toggle Plain Text)
  1. <?php
  2. $username="root";
  3. $password="";
  4. $database="dbdate";
  5.  
  6. mysql_connect(localhost,$username,$password);
  7. @mysql_select_db($database) or die("Unable to select database");
  8.  
  9. $query = "SELECT *
  10. FROM `cdate`
  11. WHERE 1
  12. LIMIT 0 , 30";
  13. $result = mysql_query($query) or die(mysql_error());
  14.  
  15. while($row = mysql_fetch_array($result)) {
  16. echo $row['date'];
  17. }
  18. ?>
  19.  
  20. <input name = "date" value="<? echo $row['date']; ?>" type="text" />
Similar Threads
Reputation Points: 8
Solved Threads: 0
Junior Poster in Training
ekseks is offline Offline
61 posts
since May 2010
Jul 30th, 2010
0
Re: setting the value in my
echo your query. copy and past in mysql db u will found error
Reputation Points: 3
Solved Threads: 15
Posting Whiz
Aamit is offline Offline
341 posts
since Apr 2008
Jul 30th, 2010
0
Re: setting the value in my
I am not sure what actually you wanna do but hope fully this may help,

1st problem: localhost is not in "" (quots)

that should be like this
mysql_connect("localhost",$username,$password);

2nd:
<input name = "date" value="<? echo $row['date']; ?>" type="text" /> is out side of loop so that $row have no value in it
see this, this will print multiple(according to the database records)input fields with date values in it
PHP Syntax (Toggle Plain Text)
  1. <?php
  2. $username="root";
  3. $password="";
  4. $database="dbdate";
  5.  
  6. mysql_connect('localhost',$username,$password);
  7. @mysql_select_db($database) or die("Unable to select database");
  8.  
  9. $query = "SELECT *
  10. FROM `cdate`
  11. WHERE 1
  12. LIMIT 0 , 30";
  13. $result = mysql_query($query) or die(mysql_error());
  14.  
  15. while($row = mysql_fetch_array($result)) {
  16. //echo $row['date'];
  17. echo "<input name = \"date\" value=\"" . $row['date'] . "\" type=\"text\" /> <br /> <br />";
  18. }
  19. ?>


or

PHP Syntax (Toggle Plain Text)
  1. <?php
  2. $username="root";
  3. $password="";
  4. $database="dbdate";
  5.  
  6. mysql_connect('localhost',$username,$password);
  7. @mysql_select_db($database) or die("Unable to select database");
  8.  
  9. $query = "SELECT *
  10. FROM `cdate`
  11. WHERE 1
  12. LIMIT 0 , 30";
  13. $result = mysql_query($query) or die(mysql_error());
  14. $row = mysql_fetch_array($result)
  15. ?>
  16. <input name = "date" value="<?php echo $row['date']; ?>" type="text" />
Last edited by katarey; Jul 30th, 2010 at 8:01 am.
Reputation Points: 39
Solved Threads: 23
Junior Poster
katarey is offline Offline
167 posts
since Jul 2005
Jul 30th, 2010
0
Re: setting the value in my
Reputation Points: 39
Solved Threads: 23
Junior Poster
katarey is offline Offline
167 posts
since Jul 2005

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: php/java integration
Next Thread in PHP Forum Timeline: PHP Code to access SQL SERVER 2008 tables





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


Follow us on Twitter


© 2011 DaniWeb® LLC