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
$username="root";
$password="";
$database="dbdate";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die("Unable to select database");

$query = "SELECT *
FROM `cdate`
WHERE 1
LIMIT 0 , 30";
$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result)) {
	echo $row['date'];
	}
?>

<input name = "date"  value="<? echo $row['date']; ?>" type="text" />

Recommended Answers

All 3 Replies

echo your query. copy and past in mysql db u will found error

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; ?>" 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
$username="root";
$password="";
$database="dbdate";

mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die("Unable to select database");

$query = "SELECT *
FROM `cdate`
WHERE 1
LIMIT 0 , 30";
$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result)) {
	//echo $row['date'];
	echo "<input name = \"date\"  value=\"" . $row['date'] . "\" type=\"text\" /> <br /> <br />";
}
?>

or

<?php
$username="root";
$password="";
$database="dbdate";

mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die("Unable to select database");

$query = "SELECT *
FROM `cdate`
WHERE 1
LIMIT 0 , 30";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result)
?>
<input name = "date"  value="<?php echo $row['date']; ?>" type="text" />
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.