Jump to content

Update will not happen


dennismonsewicz

Recommended Posts

/* EDIT MODE */

case "edit":

include "../includes/db_login.php";

 

                $query = "SELECT * FROM tblName WHERE rowid = '$rowid'";

               

                $result = mysql_query( $query );

               

                if(!$result)

                    {

                        die("Could not query the database: <br/>" . mysql_error());

                    }

               

                while($row = mysql_fetch_array($result, MYSQL_ASSOC))

{

$id = $row['rowid'];

$company = $row['company'];

$product = $row['product'];

$description = $row['description'];

$web = $row['web'];

$last = $row['last'];

$used = $row['used'];

$active = $row['active'];

 

echo '

<p class="casetext">Below is a more detailed description of <b>' . $product . '</b>.</p>

 

<form action="hrdbcase.php?action=doedit" method="post" name="form1">

<p><input type="hidden" name="rowid" value="' . $id . '" /></p>

<table border="0" align="center" cellpadding="4" style="margin-bottom: 5px;">

<tr>

<td>Company:</td>

<td><input type="text" name="company" value="' . $company . '" /></td>

</tr>

<tr>

<td>Product:</td>

<td><input type="text" name="company" value="' . $product . '" /></td>

</tr>

<tr>

<td>Description:</td>

<td><input type="text" name="company" value="' . $description . '" /></td>

</tr>

<tr>

<td>Web Address:</td>

<td><input type="text" name="company" value="' . $web . '" /></td>

</tr>

<tr>

<td>Last Used:</td>

<td><input type="text" name="company" value="' . $last . '" /></td>

</tr>

<tr>

<td>When was <b>' . $product . '</b> last used:</td>

<td><input type="text" name="company" value="' . $used . '" /></td>

</tr>

<tr>

<td>Is <b>' . $product . '</b> Active or Inactive?:</td>

<td><input type="text" name="company" value="' . $active . '" /></td>

</tr>

<tr>

<td></td>

<td><input type="submit" value="Submit" /></td>

</tr>

</table>

</form>

<p class="casetext" style="font-size: 125%;"><a href="hrdb.php">Go back to database?</a></p>

 

';

 

}

 

 

mysql_close($connection);

include "../includes/footer.php";

exit;

break;

/* END EDIT MODE*/

 

/* EDIT ACTION HELD HERE */

case "doedit":

 

include "../includes/db_login.php";

 

                $query="

UPDATE tblName

SET

company = '" . $company . "',

product = '" . $product . "',

description = '" . $description . "',

web = '" . $web . "',

last = '" . $last . "',

used = '" . $used . "',

active = '" . $active . "'

WHERE

rowid = '" . $rowid . "'

";

 

$result = mysql_query($query);

 

if(!$result)

{

die("Could not query the database: <br/>" . mysql_error());

}

 

while($row = mysql_fetch_array($result, MYSQL_ASSOC))

{

echo '<p class="casetext">Item updated</p>';

}

 

mysql_close($connection);

 

 

include "../includes/footer.php";

exit;

break;

/* END EDIT ACTION */

 

With the above code I am trying to get edit information pulling out of a database. Well When you get to the edit screen and then click submit to submit your changes all you get is a blank screen, well thats not entirely true (the header and the footer load). I have no idea why this is not working. Anyone have any ideas?

 

All help is appreciated,

 

Dennis

Link to comment
Share on other sites

Why are you processing an array as an else to if(!$result) for a mysql insert query?

 

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
                  {
                  echo '<p class="casetext">Item updated</p>';
                  }

 

I'm still new around here, but I just do:

if(!$result)
                  {
                  die("Could not query the database: 
" . mysql_error());
                  }
                  
                else{echo '<p class="casetext">Item updated</p>';
                }


 

See you get output with that

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.