Jump to content

Archived

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

LostNights

Wont Update Info

Recommended Posts

It wont update my information in the DB

[code]
<?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 } ?>
[/code]

Share this post


Link to post
Share on other sites
Won't update how? What's the mysql error that you're getting?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
When I change
[code]
$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."' ";
[/code]

to
[code]
$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' ";
[/code]

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

Share this post


Link to post
Share on other sites
action="infoupdate2.php?id=<?php =$id ?>" gave a parse error
action="infoupdate2.php?id=<?php $id ?>" didnt make a difference

Share this post


Link to post
Share on other sites
If you echo the query, I'll bet that you won't see a valid ID in the query string.

Share this post


Link to post
Share on other sites

×

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.