Jump to content

[SOLVED] MySQL Update working in one folder, but not another


skyer2000

Recommended Posts

I was working on my site at www.domain.com/temp/site/admin and decided to move it to a subdomain dev.domain.com

 

All of my query functions work when pulling data from the database, however, all of the forms used to update data have stopped working. I can't even begin to figure out what the problem is. I copy/pasted the EXACT code from one site to the other, and everything works (adding, deleting, and listing work) ... everything except for updating

 

What can be possible causes of this? I kept the other site live and it still works perfectly, however, the new subdomain's php forms will not update the database.

 

I tried putting an echo "$sql"; after the update process, but that wouldn't even show up. It seems that there is something wrong with submit? I have no idea

 

(NOTE: This is the exact same pageedit.php code that works in the other folder)

 

<?php

require_once ('../library/sql_connect.php');

$editortype=$_GET['editortype'];
if ($editortype == '1') {
require_once ('templates/editorheader.php');
} else {
require_once ('templates/adminheader.php');
}

$id=$_GET['id'];

if ($submit) {

$id   = $_POST['id'];
$title   = $_POST['title'];
$urlrewrite = $_POST['urlrewrite'];
$category = $_POST['category'];
$editortype = $_POST['editortype'];
$content = $_POST['content'];
$date = $_POST['date'];

if(!get_magic_quotes_gpc())
    {
        $title   = addslashes($title);
        $content = addslashes($content);
    }

$sql = "UPDATE content SET title='$title',urlrewrite='$urlrewrite',category='$category',editortype='$editortype',content='$content',date='$date' WHERE id='$id'";

$result = mysql_query($sql) or die ('Error in query: $sql. ' . mysql_error()); 

printf("Records Updated: %d\n <p>", mysql_affected_rows()); 
  
} 

    $sql = "SELECT * FROM content WHERE id='$id'";

    $result = mysql_query($sql);

    $page_info = mysql_fetch_array($result);

?>


<h1>Edit <?php echo $page_info['title']; ?></h1>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
<input type="hidden" name="id" value="<?php echo $id; ?>">
   <p>
      Title:<br />
      <input type="text" name="title" size="40" maxlength="40" value="<?php echo $page_info['title']; ?>" />
    </p>
<p>
      URL Rewrite:<br />
      <input type="text" name="urlrewrite" size="40" maxlength="40" value="<?php echo $page_info['urlrewrite']; ?>" />
    </p>
    <p>
      Category:<br />
      <input type="text" name="category" size="40" maxlength="40" value="<?php echo $page_info['category']; ?>" />
    </p>
<p>
      Editor Type:<br />
  <select name="editortype">
 <?php if ($editortype == '1') { ?>
  	<option name="1">HTML</option>
	<option name="0">PHP</option>
  <?php } else { ?>
    <option name="0">PHP</option>
  	<option name="1">HTML</option>
  <?php } ?>	
  </select>
    </p>
 <p>
      Content:<br />
      <textarea name="content" rows="20" cols="80"><?php echo $page_info['content']; ?></textarea>
    </p>
<p>
      Date:<br />
      <input type="text" name="date" size="40" maxlength="40" value="<?php echo $page_info['date']; ?>" />
    </p>
    <p>
      <input type="submit" name="submit" value="Submit!" />
    </p>
</form>
<?php require_once ('templates/adminfooter.php'); ?>

Some more information, when the Submit button is pressed, anything under if($submit) does not run, I've tried throwing an echo "hey"; in there but it didn't show up. That would explain why it is not updating, because its not even getting to that point to run the code.

 

I hope that generates some ideas in your heads, mine is stumped

It comes from:

 

<input type="submit" name="submit" value="Submit!" />

 

Is there a different way of handing the $submit variable when that is pressed (i still don't understand why it just doesn't work in this new folder)?

You know what, I went ahead and changed if($submit) to if ($_POST['submit'])

 

I still have no idea why it would work in one folder but not the other, but I guess since it works now I should just forget about the mystery  ???

 

Thanks for pointing me in the right direction!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.