View Full Version : Code All Of A Sudden Stopped Working
SChaput
05-30-2009, 03:48 AM
The below code has been working fine on my server for some time now, however tonight i realized it was not outputting anything. Anyone know why this is the case?
Thanks
<?php
if ($HTTP_POST_VARS['submit']) {
mysql_connect("","","");
mysql_select_db("");
$entrytext=$HTTP_POST_VARS['entrytext'];
$entrytime=$HTTP_POST_VARS['entrytime'];
$query ="INSERT INTO hmrTemp (entrytext,entrytime)";
$query.=" VALUES ($entrytext,$entrytime)";
$result=mysql_query($query);
$query1 ="SELECT id, entrytext";
$query1.=" FROM hmrTemp ORDER BY id DESC LIMIT 1";
$result1=mysql_query($query1);
while (list($id,$entrytext) =
mysql_fetch_row($result1)) {
?>
<div align="center">Post Successful. If you followed our rules, it will be visible on the main page soon!
<p>
<?php
echo "<a href='#'>[Click Here To Continue]</a>";
}}
?>
forum_amnesiac
05-30-2009, 09:07 AM
Just 2 things to suggest about your script
1 $HTTP_POST_VARS is now deprecated and replaced by $_POST, try doing this.
2 Try changing this section
$query1 ="SELECT id, entrytext";
$query1.=" FROM hmrTemp ORDER BY id DESC LIMIT 1";
$result1=mysql_query($query1);
while (list($id,$entrytext) =
mysql_fetch_row($result1)) {
?>
to this
$query1 ="SELECT *";
$query1.= ' FROM `hmrTemp` WHERE entrytext="' . $entrytext . '"'
$result1=mysql_query($query1);
$num=mysql_num_rows($result1);
if ($num != 0){
?>
SChaput
05-30-2009, 04:58 PM
Still not having any luck.
<?php
if ($_POST['submit']) {
mysql_connect("freshsql.com:3306","","");
mysql_select_db("");
$entrytext=$_POST['entrytext'];
$entrytime=$_POST['entrytime'];
$query ="INSERT INTO hmr entrytext,entrytime VALUES $entrytext, $entrytime";
$result=mysql_query($query);
?>
<div align="center">Post Successful. If you followed our rules, it will be visible on the main page soon!
<p>
<?php
}
?>
Thats the code to add to the database...to GET to that page, i use this form.
<form method="POST" action="addentry.php">
<table width="143" border="0" align="center" cellpadding="3" cellspacing="3">
<tr>
<td width="131"><p align="left">
text here
<textarea name="entrytext" cols="45" rows="5" wrap="physical" id="entrytext"></textarea>
<input type="submit" name="submit" value="Submit">
</td>
</tr>
</table>
</form>
Still no luck adding anything to the database.
forum_amnesiac
05-30-2009, 05:02 PM
Where do you get the entrytime variable from?
SChaput
05-30-2009, 05:55 PM
I'm sorry i should have taken that out, im not using it anymore.
<?php
if ($_POST['submit']) {
mysql_connect("localhost","",");
mysql_select_db("");
$entrytext=$_POST['entrytext'];
$query ="INSERT INTO hmrTemp entrytext";
$query.=" VALUES $entrytext";
$result=mysql_query($query);
?>
<div align="center">Post Successful. If you followed our rules, it will be visible on the main page soon!
<p>
<?php
}
?>
forum_amnesiac
05-31-2009, 07:21 AM
Have you tried it again since taking that field out.
PHP will not perform the record INSERT if you are trying to use a non-existent variable
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.