Ga het even simpel houden door me 3 docs te posten
alle eerst input.html is een simpel formpje waarmee ik gegevens wil laten inserten door insert.php
<html>
<form action="insert.php" method="post">
Quote: <br><TEXTAREA name="quote" rows="4" cols="30"></TEXTAREA><P>
User: <input type="text" name="QCharacter"><p>
<input type="Submit" value="Click me now!!">
</form>
</html>
mijn insert.php
<?
if($_POST['quote']=="")
{
print("Sorry, we don't do blank stuff, try again <a href=input.html>here</a>");
echo "<br>Or go to the Quotes section <a href=output.php>here</a>";
}else{
include("connect.php");
$query = "INSERT INTO quotes(QUOTE, Q_USER,TIME)
VALUES('$quote','$QCharacter', NOW())";
mysql_query($query) or die("Error executing query");
mysql_close();
echo "Good job, would you like to view the stats now?
Go here then <a href=output.php>output</a>";
}
?>
mijn tabel bestaat uit
Veld Type Attributen Null Standaardwaarde Extra Actie
ID int(11) Nee auto_increment
QUOTE text Nee
Q_USER text Nee
TIME timestamp(14) Ja NULL
mijn output.php is dit
<html>
<?
include("connect.php");
$query="SELECT * FROM quotes";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "<b><center>Quotes Section</b><br><br>";
$i=0;
echo "<table border=3 width=100% CELLPADDING=3 CELLSPACING=0><tr>";
while ($i < $num) {
$ID=mysql_result($result,$i,ID);
$quote=mysql_result($result,$i,"QUOTE");
$Q_USER=mysql_result($result,$i,"Q_USER");
$time=mysql_result($result,$i,"TIME");
$format_time=date("l dS of F Y h:i:s A", $time);
echo "<tr>
<td WIDTH=75 align=center>$ID</td>
<td>$quote</td>
<td WIDTH=125>$Q_USER</td>
<td> $format_time</td></tr>";
++$i;
}
?>
<a href=input.html>Go back to the input form</a>
</html>
Nu 2 probleempjes
alle eerst krijg ik door dat NOW() cijfertjes die ik wil formatteren, maar niet weet hoe het moet: mijn output, date("l dS of F Y h:i:s A", $time); ( en $time is dus uitkomst bij NOW(), krijgt altijd Tuesday 19th of January 2038 04:14:07 AM
en ik krijg behalve mijn ID en dus TIME verder niets in mijn database!
Oftewel quote en q_user is gewoon blank/leeg terwijl ik toch een if loop heb gemaakt dat als textarea van quote leeg is, dat het dan een foutmelding geeft, dus ik heb wel degelijk iets ingevuld dus ik snap het ook niet meer
graag hulp voor een php nieweling.
alle eerst input.html is een simpel formpje waarmee ik gegevens wil laten inserten door insert.php
<html>
<form action="insert.php" method="post">
Quote: <br><TEXTAREA name="quote" rows="4" cols="30"></TEXTAREA><P>
User: <input type="text" name="QCharacter"><p>
<input type="Submit" value="Click me now!!">
</form>
</html>
mijn insert.php
<?
if($_POST['quote']=="")
{
print("Sorry, we don't do blank stuff, try again <a href=input.html>here</a>");
echo "<br>Or go to the Quotes section <a href=output.php>here</a>";
}else{
include("connect.php");
$query = "INSERT INTO quotes(QUOTE, Q_USER,TIME)
VALUES('$quote','$QCharacter', NOW())";
mysql_query($query) or die("Error executing query");
mysql_close();
echo "Good job, would you like to view the stats now?
Go here then <a href=output.php>output</a>";
}
?>
mijn tabel bestaat uit
Veld Type Attributen Null Standaardwaarde Extra Actie
ID int(11) Nee auto_increment
QUOTE text Nee
Q_USER text Nee
TIME timestamp(14) Ja NULL
mijn output.php is dit
<html>
<?
include("connect.php");
$query="SELECT * FROM quotes";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "<b><center>Quotes Section</b><br><br>";
$i=0;
echo "<table border=3 width=100% CELLPADDING=3 CELLSPACING=0><tr>";
while ($i < $num) {
$ID=mysql_result($result,$i,ID);
$quote=mysql_result($result,$i,"QUOTE");
$Q_USER=mysql_result($result,$i,"Q_USER");
$time=mysql_result($result,$i,"TIME");
$format_time=date("l dS of F Y h:i:s A", $time);
echo "<tr>
<td WIDTH=75 align=center>$ID</td>
<td>$quote</td>
<td WIDTH=125>$Q_USER</td>
<td> $format_time</td></tr>";
++$i;
}
?>
<a href=input.html>Go back to the input form</a>
</html>
Nu 2 probleempjes
alle eerst krijg ik door dat NOW() cijfertjes die ik wil formatteren, maar niet weet hoe het moet: mijn output, date("l dS of F Y h:i:s A", $time); ( en $time is dus uitkomst bij NOW(), krijgt altijd Tuesday 19th of January 2038 04:14:07 AM
en ik krijg behalve mijn ID en dus TIME verder niets in mijn database!
Oftewel quote en q_user is gewoon blank/leeg terwijl ik toch een if loop heb gemaakt dat als textarea van quote leeg is, dat het dan een foutmelding geeft, dus ik heb wel degelijk iets ingevuld dus ik snap het ook niet meer
graag hulp voor een php nieweling.