Jump to content


Photo

Wont Update Info


  • Please log in to reply
6 replies to this topic

#1 LostNights

LostNights
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 10 May 2006 - 04:39 PM

It wont update my information in the DB

<?php

$id = $_GET['id'];

    if (isset($_POST['submitbutton'])) {

mysql_connect('localhost','user','user') or die ("Cannot connect to server");

mysql_select_db("photodirectory") or die ("Cannot connect to database");

$query = "UPDATE corporatelist SET firstname='$_POST[firstname]', lastname='$_POST[lastname]',title='$_POST[title]',department='$_POST[department]',office='$_POST[office]',phone='$_POST[phone]' WHERE sku = '".$id."' ";
$result = mysql_query($query);

        if (!$result) { 
            echo "There was a problem with your entry. <a href='infoupdate2.php'>Back</a>";
        } else {
            echo "Your information has been changed."; 
        }
    } else {
?>
<?php echo $id; ?>
<form action="infoupdate2.php" method="post">

<p>First Name: <input type="text" maxlength="30" size="32" name="firstname" /></p>

<p>Last Name: <input type="text" maxlength="30" size="32" name="lastname" /></p>

<p>Job Title: <input type="text" maxlength="55" size="57" name="title" /></p>

<p>Department: <input type="text" maxlength="18" size="20" name="department" /></p>

<p>Office: <input type="text" maxlength="4" size="6" name="office" /></p>

<p>Phone Number: <input type="text" maxlength="4" size="6" name="phone" /></p>

<input type="submit" value="Enter Employee Information" name="submitbutton" />

</form>

<?php } ?>


#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 10 May 2006 - 05:36 PM

Won't update how? What's the mysql error that you're getting?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 LostNights

LostNights
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 10 May 2006 - 06:24 PM

No error, just cycles to the "Your info has been updated" line, but it doesnt update that line in the database.
Could it be the variable from the other page? Its just a link variable. the ID echo's out fine.

#4 LostNights

LostNights
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 10 May 2006 - 06:55 PM

When I change
$query = "UPDATE corporatelist SET firstname='$_POST[firstname]', lastname='$_POST[lastname]',title='$_POST[title]',department='$_POST[department]',office='$_POST[office]',phone='$_POST[phone]' WHERE sku = '".$id."' ";

to
$query = "UPDATE corporatelist SET firstname='$_POST[firstname]', lastname='$_POST[lastname]',title='$_POST[title]',department='$_POST[department]',office='$_POST[office]',phone='$_POST[phone]' WHERE lastname = 'Benko' ";

That changes it for the person whos last name is Benko, so its a problem with the variable.

#5 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 10 May 2006 - 07:44 PM

action="infoupdate2.php?id=<?=$id?>"

Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#6 LostNights

LostNights
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 10 May 2006 - 08:14 PM

action="infoupdate2.php?id=<?php =$id ?>" gave a parse error
action="infoupdate2.php?id=<?php $id ?>" didnt make a difference

#7 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 10 May 2006 - 08:47 PM

If you echo the query, I'll bet that you won't see a valid ID in the query string.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users