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'); ?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.