Results 1 to 6 of 6

Thread: Code All Of A Sudden Stopped Working

  1. #1
    Join Date
    Feb 2008
    Posts
    90
    Thanks
    3
    Thanked 2 Times in 2 Posts

    Default Code All Of A Sudden Stopped Working

    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

    Code:
    <?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>";
          
          }}
          ?>

  2. #2
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    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
    PHP Code:
        $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
    PHP Code:
         $query1 ="SELECT *";
       
    $query1.= ' FROM `hmrTemp` WHERE entrytext="' $entrytext '"'
       
    $result1=mysql_query($query1);
       
    $num=mysql_num_rows($result1);
        if (
    $num != 0){
        
    ?> 

  3. #3
    Join Date
    Feb 2008
    Posts
    90
    Thanks
    3
    Thanked 2 Times in 2 Posts

    Default

    Still not having any luck.
    Code:
    <?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.
    Code:
    <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.

  4. #4
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    Where do you get the entrytime variable from?

  5. #5
    Join Date
    Feb 2008
    Posts
    90
    Thanks
    3
    Thanked 2 Times in 2 Posts

    Default

    I'm sorry i should have taken that out, im not using it anymore.
    Code:
    <?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
      }
      ?>

  6. #6
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •