Hello,
I have a problem with the records inserted in my database.I have a form where i upload text and print this text through echo on the screen.Yesterday,i had no problem and every record was apperead normally.But after the insertion of about 100 records i have problem and it appears blank record on every text i submit.I can’t understand what’s wrong.Here the code:
index.php
[code=php]<form action=”insert.php” method=”POST” name=”Wordform”><input type=hidden name=”color” value=”<?php echo sprintf(“#%x%x%x”, rand(0,255), rand(0,255), rand(0,255)); ?>”><input name=”message” style=”width:40%; padding:3px;” type=”text” name=”text”><input style=”cursor:pointer; cursor:hand;” type=”submit” style=”font-size:14px;” value=”Upload Text”>
<?php
$color = sprintf(“#%x%x%x”, rand(0,255), rand(0,255), rand(0,255));
$con = mysql_connect(“localhost”,”root”,””);
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}
mysql_select_db(“data”, $con); $result = mysql_query(“SELECT * FROM text ORDER BY num DESC LIMIT 100″);
while($row = mysql_fetch_array($result))
{
echo ‘<font color=”‘.$row[‘color’].'”>’ . $row[‘text’] . ‘</font>’;
echo “ ”;
}
mysql_close($con);
?>
insert.php
[code=php]<?php
// Connects to your Database
mysql_connect(“localhost”, “root”, “”) or die(mysql_error());
mysql_select_db(“data”) or die(mysql_error());
// now we insert it into the database
mysql_query(“INSERT INTO text (text, color)
VALUES (‘”.$_POST[‘text’].”‘ , ‘” .$_POST[‘color’]. “‘)”) or die(mysql_error());
{ header(“Location:index.php”);
}
?>