dean7 Posted August 27, 2009 Share Posted August 27, 2009 Hi all, Ive got a news script for my website witch can show updates etc main.php <?php session_start(); include "config.php"; include "includes/functions.php"; ?> <html> <head> <link rel=stylesheet href=includes/in.css type=text/css> <title>Updates</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head> <body> <table class="Main" width="50%" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#000000"> <tr><td background="includes/grad.gif" height="39" colspan="2" class="TableHeading"><b><u>Game updates</u></b></td> </tr> <? $select_updates=mysql_query("SELECT * FROM updates ORDER BY id DESC"); while($the=mysql_fetch_object($select_updates)){ ?> <tr><td background="includes/grad.jpg" class='TableSub' height=20 width=70%><center><b>By: <? echo "<A href='profile.php?viewuser=$the->username'>$the->username</a>"; ?> On: <? echo "$the->time"; ?></b></center></td></tr> <tr><td class='TableArea' colspan=2 width=30%><? echo "$the->update<p>"; ?></td></tr> <? } ?> </table> <br> <?php if ($fetch->level == "owner"){ if (strip_tags($_POST['submit']) && (strip_tags($_POST['update'] != ""))){ $update=strip_tags($_POST['update']); $date = gmdate('Y-m-d h:i:s'); mysql_query("INSERT INTO `updates` ( `id` , `username` , `time` , `update` ) VALUES ( '', '$username', '$date', '$update' )"); echo "Update has been added"; } } ?> <form name="form1" method="post" action=""> <table width="450x" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#000000" class="Main"> <tr><td class="TableHeading">Add an update</td></tr> <tr><td class="TableArea" align="center">Add an update: <textarea name="update" cols="80" rows="5" id="update"></textarea> <input name="submit" type="submit" id="submit" value="Add update"><br> </td></tr> </table> </form> <p> </p> <table align="center" width="482" height="47" border="2" bgcolor="#000000"> <tr><td width="470"> <center> <p><b><img src="Images/question mark.jpg"></b><br> <strong><font color="#CCCCCC">Info about website be posted here soon </font></strong> </p> </center> </table> </tr></td> </body> </html> But were it is ment to insert into the database its not.. Any one know why? Thanks Link to comment https://forums.phpfreaks.com/topic/172099-solved-insert-into/ Share on other sites More sharing options...
JonnoTheDev Posted August 27, 2009 Share Posted August 27, 2009 Where is the $fetch object instantiated? I can't seem to find any ref to it in your script so your condition is always false. <?php if ($fetch->level == "owner"){ Link to comment https://forums.phpfreaks.com/topic/172099-solved-insert-into/#findComment-907387 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.