Jump to content

trying to update fields


kikilahooch

Recommended Posts

Hi, I have a page where i want to be able to update records stored in my database. What I am doing is I first have a list of all products with images displayed beside them. To update a record I click on an image and this then brings me to a page called admin_update2.php. What should happen here is that a table filled with all of the details of the product clicked on appears. The fields stored on each product are:

prodId int(10)
shopName varchar(30)
prodName varchar(40)
dept varchar(20)
brand varchar(20)
type varchar(20)
image varchar(60)
price double(3,2)
NoInStock int(3)

The fields prodId and shopName are not editable because these will always stay the same. What happens when I click on an image is the table appears with all of the values on the product showing apart from prodName (which is the 1st field which can be updated). prodName gets deleted when I click on the image and a message saying "system error" appears.

Can anybody help me with this pls. Newbie with a deadline here!!

[code]
<?php #Script 7.3 - register.php
include "db.php";



$prodId = 0;  // UPDATED
$prodId = $_GET['prodId'];


$sql= "select * from product where prodId=$prodId";


$result = mysql_query($sql,$conn) or die(mysql_error()); //comment out if not working

if (mysql_num_rows($result) == 1) {

//if authorized, get the values of prodId, shopName...

$prodId = mysql_result($result, 0, 'prodId');
$shopName = mysql_result($result, 0, 'shopName');
$dept = mysql_result($result, 0, 'dept');
$brand = mysql_result($result, 0, 'brand');
$type = mysql_result($result, 0, 'type');
$image = mysql_result($result, 0, 'image');
$price = mysql_result($result, 0, 'price');



$query2 = mysql_query("UPDATE product SET prodName='$prodName', dept='$dept', brand='$brand', type='$type', image='$image', price='$price' WHERE prodId ='$prodId' and shopName='$shopName'");

$result = @mysql_query($query2);
if($result){
echo'<p align=center><font color="#333333"><b>UPDATED SUCCESSFULLY</b></font></p>';
}

else{
echo'<h1> System Error </h1>';
}



$query = "SELECT * FROM product WHERE prodId = '$prodId' and shopName='$shopName'";


$result = @mysql_query($query);
if($result){
echo'


<form action="admin_update2.php" method="post">



<center>
<table align="center" cellspacing="0" cellpadding="5" bgcolor="#ffffff" border=1 bordercolor="#2696b8">';

while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
echo'


<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Id </b></center></td>
<td align="left">'.$row['prodId'].'</td>




<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Shop Name</b></td>
<td align="left">'.$row['shopName'].'</td>

<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Name</b></td>
<td align="left"><input type="text" name="prodName" size="30" maxlength="30" value="'.$row['prodName'].'"/></td>

<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Department</b></td>
<td align="left"><input type="text" name="dept" size="20" maxlength="20" value="'.$row['dept'].'"/></td>

.....

<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Price</b></td>
<td align="left"><input type="text" name="price" size="50" maxlength="50" value="'.$row['price'].'"/></td>



</tr>';
}
echo'


<tr><td><center><input type="submit" name="submit" value="UPDATE"/>
<input type="reset" value="CLEAR FORM"></p></center>


<input type="hidden" name="prodId" value='.$prodId.'>
<input type="hidden" name="shopName" value='.$sName.'>



<input type="hidden" name="submittedUpdate" value="TRUE"/></form></td></tr>

</table>

';
}

}

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

$prodId = trim($_POST['prodId']);
$shopName= $_GET['shopName'];





$query = "SELECT * FROM product WHERE prodId = '$prodId' and shopName='$shopName'";




$result = @mysql_query($query);
if($result){
echo'


<form action="admin_update.php" method="post">



<center>
<table align="center" cellspacing="0" cellpadding="5" bgcolor="#ffffff" border=1 bordercolor="#2696b8">';

while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
echo'


<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Id</b></center></td>
<td align="left">'.$row['prodId'].'</td>



<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Shop Name</b></td>
<td align="left">'.$row['shopName'].'</td>

<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Name</b></td>
<td align="left"><input type="text" name="prodName" size="30" maxlength="30" value="'.$row['prodName'].'"/></td>

<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Department</b></td>
<td align="left"><input type="text" name="dept" size="20" maxlength="20" value="'.$row['dept'].'"/></td>

.....

<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Price</b></td>
<td align="left"><input type="text" name="price" size="50" maxlength="50" value="'.$row['price'].'"/></td>





</tr>';
}
echo'


<tr><td><center><input type="submit" name="submit" value="UPDATE"/>
<!--<input type="reset" value="CLEAR FORM"></p></center>-->
<tr><td><center>



<input type="hidden" name="prodId" value='.$prodId.'>
<input type="hidden" name="shopName" value='.$shopName.'>



<input type="hidden" name="submittedUpdate" value="TRUE"/></form></td></tr>

</table>
';

}

else{
echo'<h1> System Error1 </h1> table ';
exit();
}

}
mysql_close();

?>



</body>
</html>

[/code]
Link to comment
Share on other sites

Looks like your query is failing. Change this:
[code]$result = @mysql_query($query2);
if($result){
echo'<p align=center><font color="#333333"><b>UPDATED SUCCESSFULLY</b></font></p>';
}

else{
echo'<h1> System Error </h1>';
}[/code]
To this:
[code]$result = @mysql_query($query2) or die("Unable to perform query <code>" . $query2 . "</code><br /><br />" . mysql_error());

echo'<p align=center><font color="#333333"><b>UPDATED SUCCESSFULLY</b></font></p>';[/code]

You should now get an error returned from MySQL why your query is failing. POst the error you get here.
Link to comment
Share on other sites

OMG, I should of spotted this earlier but you have already ran the query. The $query2 variable holds the result of the query, then you run $query2 through mysql_query again! Have a look at the code below:
[code=php:0]// Youa re running the query here
$query2 = mysql_query("UPDATE product SET prodName='$prodName', dept='$dept', brand='$brand', type='$type',
image='$image', price='$price' WHERE prodId ='$prodId' and shopName='$shopName'");

// Here you pass $query2 to run the query.
// But $query 2 alleady holds the result of the query
$result = @mysql_query($query2);[/code]

So use this instead for $query2:
[code]$query2 = UPDATE product SET prodName='$prodName', dept='$dept', brand='$brand', type='$type',
image='$image', price='$price' WHERE prodId ='$prodId' and shopName='$shopName'";[/code]
Link to comment
Share on other sites

afther all i just done dam didnt see that my self

[code]


$query2 = mysql_query("UPDATE `product` SET `prodName`='$prodName', `dept`='$dept', `brand`='$brand', `type`='$type', `image`='$image', `price`='$price' WHERE `prodId` ='$prodId' and `shopName`='$shopName'");

$result = @mysql_query($query2);
if($result){
echo'<p align=center><font color="#333333"><b>UPDATED SUCCESSFULLY</b></font></p>';
}

else{
echo'<h1> System Error </h1>';
}

[/code]
Link to comment
Share on other sites

ok when I did what wildteen said it still deletes the prodname but it gives the message of UPDATED SUCCESSFULLY rather than System Error which it was doing before. Just to make sure I was getting you right I'll put up that part of the code again (Really dont know what I'm doing so I could be messing up your simple instructions!lol)

[code]
$query2 = "UPDATE product SET prodName='$prodName', dept='$dept', brand='$brand', type='$type', image='$image', price='$price' WHERE prodId ='$prodId' and shopName='$shopName'";



$result = @mysql_query($query2) or die("Unable to perform query <code>" . $query2 . "</code><br /><br />" . mysql_error());

echo'<p align=center><font color="#333333"><b>UPDATED SUCCESSFULLY</b></font></p>';[/code]
Link to comment
Share on other sites

have a look at this i change all the query names as you was running to meny querys with the same name here you go.

also added all the die for the querys and also took away the mysql_close as it's not needed.


emample only not tested.


[code]
<?php #Script 7.3 - register.php
include "db.php";



$prodId = 0;   // UPDATED
$prodId = $_GET['prodId'];


$sql= "select * from product where prodId=$prodId";


$result = mysql_query($sql,$conn) or die(mysql_error()); //comment out if not working

if (mysql_num_rows($result) == 1) {

//if authorized, get the values of prodId, shopName...

$prodId = mysql_result($result, 0, 'prodId');
$shopName = mysql_result($result, 0, 'shopName');
$dept = mysql_result($result, 0, 'dept');
$brand = mysql_result($result, 0, 'brand');
$type = mysql_result($result, 0, 'type');
$image = mysql_result($result, 0, 'image');
$price = mysql_result($result, 0, 'price');



$query1 = mysql_query("UPDATE product SET prodName='$prodName', dept='$dept', brand='$brand', type='$type', image='$image', price='$price' WHERE prodId ='$prodId' and shopName='$shopName'");

$result1 = @mysql_query($query1)or dir("query 1");
if($result1){
echo'<p align=center><font color="#333333"><b>UPDATED SUCCESSFULLY</b></font></p>';
}

else{
echo'<h1> System Error </h1>';
}



$query2 = "SELECT * FROM product WHERE prodId = '$prodId' and shopName='$shopName'";


$result2 = @mysql_query($query)or dir("query 2");
if($result2){
echo'


<form action="admin_update2.php" method="post">



<center>
<table align="center" cellspacing="0" cellpadding="5" bgcolor="#ffffff" border=1 bordercolor="#2696b8">';

while($row = mysql_fetch_array($result2, MYSQL_ASSOC)){
echo'


<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Id </b></center></td>
<td align="left">'.$row['prodId'].'</td>




<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Shop Name</b></td>
<td align="left">'.$row['shopName'].'</td>

<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Name</b></td>
<td align="left"><input type="text" name="prodName" size="30" maxlength="30" value="'.$row['prodName'].'"/></td>

<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Department</b></td>
<td align="left"><input type="text" name="dept" size="20" maxlength="20" value="'.$row['dept'].'"/></td>

.....

<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Price</b></td>
<td align="left"><input type="text" name="price" size="50" maxlength="50" value="'.$row['price'].'"/></td>



</tr>';
}
echo'


<tr><td><center><input type="submit" name="submit" value="UPDATE"/>
<input type="reset" value="CLEAR FORM"></p></center>


<input type="hidden" name="prodId" value='.$prodId.'>
<input type="hidden" name="shopName" value='.$sName.'>



<input type="hidden" name="submittedUpdate" value="TRUE"/></form></td></tr>

</table>

';
}

}

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

$prodId = trim($_POST['prodId']);
$shopName= $_GET['shopName'];





$query3 = "SELECT * FROM product WHERE prodId = '$prodId' and shopName='$shopName'";




$result3 = @mysql_query($query3)or die("query 3");
if($result3){
echo'


<form action="admin_update.php" method="post">



<center>
<table align="center" cellspacing="0" cellpadding="5" bgcolor="#ffffff" border=1 bordercolor="#2696b8">';

while($row = mysql_fetch_array($result3, MYSQL_ASSOC)){
echo'


<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Id</b></center></td>
<td align="left">'.$row['prodId'].'</td>



<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Shop Name</b></td>
<td align="left">'.$row['shopName'].'</td>

<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Name</b></td>
<td align="left"><input type="text" name="prodName" size="30" maxlength="30" value="'.$row['prodName'].'"/></td>

<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Department</b></td>
<td align="left"><input type="text" name="dept" size="20" maxlength="20" value="'.$row['dept'].'"/></td>

.....

<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Price</b></td>
<td align="left"><input type="text" name="price" size="50" maxlength="50" value="'.$row['price'].'"/></td>





</tr>';
}
echo'


<tr><td><center><input type="submit" name="submit" value="UPDATE"/>
<!--<input type="reset" value="CLEAR FORM"></p></center>-->
<tr><td><center>



<input type="hidden" name="prodId" value='.$prodId.'>
<input type="hidden" name="shopName" value='.$shopName.'>



<input type="hidden" name="submittedUpdate" value="TRUE"/></form></td></tr>

</table>
';

}

else{
echo'<h1> System Error1 </h1> table ';
exit();
}

}


?>

</body>
</html>

[/code]
Link to comment
Share on other sites

Try this:
[code]<?php
#Script 7.3 - register.php
include "db.php";

$prodId = 0;  // UPDATED
$prodId = isset($_GET['prodId']) && is_numeric($_GET['prodId']) ? $_GET['prodId'] : 'INVALID';

if($prodid == 'INVALID')
{
    die('<h1>Invalid Production Identification</h1>');
}

$sql = "SELECT * FROM product WHERE prodId=$prodId";

$result = mysql_query($sql, $conn) or die(mysql_error()); //comment out if not working

if (mysql_num_rows($result) == 1)
{
    //if authorized, get the values of prodId, shopName...
$prodId = mysql_result($result, 0, 'prodId');
$shopName = mysql_result($result, 0, 'shopName');
$dept = mysql_result($result, 0, 'dept');
$brand     = mysql_result($result, 0, 'brand');
$type = mysql_result($result, 0, 'type');
$image  = mysql_result($result, 0, 'image');
$price     = mysql_result($result, 0, 'price');

    $query1 = "UPDATE product SET prodName='$prodName', dept='$dept', brand='$brand', type='$type', image='$image', price='$price' WHERE prodId ='$prodId' and shopName='$shopName'";

$result = @mysql_query($query1) or die("Unable to perform query1 <code>" . $query1 . "</code><br /><br />" . mysql_error());

    echo'<p align=center><font color="#333333"><b>UPDATED SUCCESSFULLY</b></font></p>';

    $query2 = "SELECT * FROM product WHERE prodId = '$prodId' and shopName='$shopName'";

    $result2 = @mysql_query($query) or die("Unable to perform query2 <code>" . $query2 . "</code><br /><br />" . mysql_error());

    echo'<form action="admin_update2.php" method="post">
  <center>
    <table align="center" cellspacing="0" cellpadding="5" bgcolor="#ffffff" border=1 bordercolor="#2696b8">
      ';

    while($row = mysql_fetch_array($result2, MYSQL_ASSOC))
    {
        echo'<tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Id </b></center></td>
        <td align="left">' . $row['prodId'] . '</td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Shop Name</b></td>
        <td align="left">' . $row['shopName'] . '</td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Name</b></td>
        <td align="left"><input type="text" name="prodName" size="30" maxlength="30" value="' . $row['prodName'] . '"/></td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Department</b></td>
        <td align="left"><input type="text" name="dept" size="20" maxlength="20" value="' . $row['dept'] . '"/></td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Price</b></td>
        <td align="left"><input type="text" name="price" size="50" maxlength="50" value="' . $row['price'] . '"/></td>
      </tr>
';
    }

    echo'      <tr>
        <td align="center">
          <p><input type="submit" name="submit" value="UPDATE"/>
  <input type="reset" value="CLEAR FORM"></p>

          <input type="hidden" name="prodId" value=' . $prodId . '>
          <input type="hidden" name="shopName" value=' . $sName . '>

          <input type="hidden" name="submittedUpdate" value="TRUE"/>
        </td>
      </tr>
    </table>
  </center>
</form>';
}

if(isset($_POST['submitted']))
{
    $prodId = trim($_POST['prodId']);
$shopName= $_GET['shopName'];

    $query3 = "SELECT * FROM product WHERE prodId = '$prodId' and shopName='$shopName'";

    $result3 = @mysql_query($query3) or die("Unable to perform query3 <code>" . $query3 . "</code><br /><br />" . mysql_error());

    echo'<form action="admin_update.php" method="post">
  <center>
    <table align="center" cellspacing="0" cellpadding="5" bgcolor="#ffffff" border=1 bordercolor="#2696b8">
      ';

    while($row = mysql_fetch_array($result3, MYSQL_ASSOC))
    {
        echo'<tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Id</b></center></td>
        <td align="left">' . $row['prodId'] . '</td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Shop Name</b></td>
        <td align="left">' . $row['shopName'] . '</td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Name</b></td>
        <td align="left"><input type="text" name="prodName" size="30" maxlength="30" value="' . $row['prodName'] . '"/></td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Department</b></td>
        <td align="left"><input type="text" name="dept" size="20" maxlength="20" value="' . $row['dept'] . '"/></td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Price</b></td>
        <td align="left"><input type="text" name="price" size="50" maxlength="50" value="' . $row['price'] . '"/></td>
      </tr>
      ';
    }
    echo'<tr>
        <td align="center">
          <input type="submit" name="submit" value="UPDATE"/>
          <!--<input type="reset" value="CLEAR FORM"></p>-->
        </td>
      </tr>
    <tr>
        <td align="center">
          <input type="hidden" name="prodId" value=' . $prodId . '>
          <input type="hidden" name="shopName" value=' . $shopName . '>
          <input type="hidden" name="submittedUpdate" value="TRUE"/>
        </td>
      </tr>
    </table>
  </center>
</form>';
}

?>
</body>
</html>[/code]
Link to comment
Share on other sites

give this a quick go ok

back up your existing work is this is classed as an example of you current work thank you.


[code]
<?php #Script 7.3 - register.php

include "db.php";

$prodId = 0;   // UPDATED
$prodId = $_GET['prodId'];


$sql= "select * from product where prodId=$prodId";

$result = mysql_query($sql,$conn) or die(mysql_error()); //comment out if not working

while ($record=mysql_fetch_assoc($result)){

$prodId=$record['prodid'];
$shopName=$record['shopname'];
$dept=$record['dept'];
$brand=$record['brand'];
$type=$record['type'];
$image=$record['image'];
$price=$record['price'];



if (mysql_num_rows($result) == 1) {



$query1 = mysql_query("UPDATE product SET prodName='$prodName', dept='$dept', brand='$brand', type='$type', image='$image', price='$price' WHERE prodId ='$prodId' and shopName='$shopName'");

$result1 = @mysql_query($query1)or dir("query 1");


if($result1){
echo'<p align=center><font color="#333333"><b>UPDATED SUCCESSFULLY</b></font></p>';

}else{
echo'<h1> System Error </h1>';
}


$query2 = "SELECT * FROM product WHERE prodId = '$prodId' and shopName='$shopName'";
$result2 = @mysql_query($query)or dir("query 2");

if($result2){

echo'



<form action="admin_update2.php" method="post">


<center>
<table align="center" cellspacing="0" cellpadding="5" bgcolor="#ffffff" border=1 bordercolor="#2696b8">';

while($row = mysql_fetch_array($result2, MYSQL_ASSOC)){
echo'


<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Id </b></center></td>
<td align="left">'.$row['prodId'].'</td>




<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Shop Name</b></td>
<td align="left">'.$row['shopName'].'</td>

<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Name</b></td>
<td align="left"><input type="text" name="prodName" size="30" maxlength="30" value="'.$row['prodName'].'"/></td>

<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Department</b></td>
<td align="left"><input type="text" name="dept" size="20" maxlength="20" value="'.$row['dept'].'"/></td>

.....

<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Price</b></td>
<td align="left"><input type="text" name="price" size="50" maxlength="50" value="'.$row['price'].'"/></td>



</tr>';
}
echo'


<tr><td><center><input type="submit" name="submit" value="UPDATE"/>
<input type="reset" value="CLEAR FORM"></p></center>


<input type="hidden" name="prodId" value='.$prodId.'>
<input type="hidden" name="shopName" value='.$sName.'>



<input type="hidden" name="submittedUpdate" value="TRUE"/></form></td></tr>

</table>

';
}

}

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

$prodId = trim($_POST['prodId']);
$shopName= $_GET['shopName'];





$query3 = "SELECT * FROM product WHERE prodId = '$prodId' and shopName='$shopName'";




$result3 = @mysql_query($query3)or die("query 3");
if($result3){
echo'


<form action="admin_update.php" method="post">



<center>
<table align="center" cellspacing="0" cellpadding="5" bgcolor="#ffffff" border=1 bordercolor="#2696b8">';

while($row = mysql_fetch_array($result3, MYSQL_ASSOC)){
echo'


<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Id</b></center></td>
<td align="left">'.$row['prodId'].'</td>



<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Shop Name</b></td>
<td align="left">'.$row['shopName'].'</td>

<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Name</b></td>
<td align="left"><input type="text" name="prodName" size="30" maxlength="30" value="'.$row['prodName'].'"/></td>

<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Department</b></td>
<td align="left"><input type="text" name="dept" size="20" maxlength="20" value="'.$row['dept'].'"/></td>

.....

<tr><td align="left" bgcolor="#2696b8"><center><font color="black"><b>Price</b></td>
<td align="left"><input type="text" name="price" size="50" maxlength="50" value="'.$row['price'].'"/></td>





</tr>';
}
echo'


<tr><td><center><input type="submit" name="submit" value="UPDATE"/>
<!--<input type="reset" value="CLEAR FORM"></p></center>-->
<tr><td><center>



<input type="hidden" name="prodId" value='.$prodId.'>
<input type="hidden" name="shopName" value='.$shopName.'>



<input type="hidden" name="submittedUpdate" value="TRUE"/></form></td></tr>

</table>
';

}

else{
echo'<h1> System Error1 </h1> table ';
exit();
}

}
}
mysql_close();

?>



</body>
</html>
[/code]
Link to comment
Share on other sites

Oops missed typed something Change this line:
[code]$result2 = @mysql_query($query) or die("Unable to perform query2 <code>" . $query2 . "</code><br /><br />" . mysql_error());[/code]
to this:
[code]$result2 = @mysql_query($query2) or die("Unable to perform query2 <code>" . $query2 . "</code><br /><br />" . mysql_error());[/code]
Link to comment
Share on other sites

kikilahooch Did you try the correction I suggested in my last post?
[quote author=wildteen88 link=topic=106622.msg426669#msg426669 date=1157221176]
Oops missed typed something Change this line:
[code]$result2 = @mysql_query($query) or die("Unable to perform query2 <code>" . $query2 . "</code><br /><br />" . mysql_error());[/code]
to this:
[code]$result2 = @mysql_query($query2) or die("Unable to perform query2 <code>" . $query2 . "</code><br /><br />" . mysql_error());[/code]
[/quote]
Link to comment
Share on other sites

wildteen when your finished can you kindly exsplain this code to me as i never in my life seen it done like this cheers m8

$prodId = mysql_result($result, 0, 'prodId');
$shopName = mysql_result($result, 0, 'shopName');
$dept = mysql_result($result, 0, 'dept');
$brand = mysql_result($result, 0, 'brand');
$type = mysql_result($result, 0, 'type');
$image = mysql_result($result, 0, 'image');
$price = mysql_result($result, 0, 'price');
Link to comment
Share on other sites

In query1:
[b]UPDATE product SET prodName='$prodName', dept='$dept', brand='$brand', type='$type', image='$image', price='$price'
WHERE prodId ='$prodId' and shopName='$shopName'[/b]
You use $prodName to update the prodName field. Where does $prodName come from, as this is mostl ikey why it is being [b]deleted[/b] as $prodName doesnt exist

[b]To redarrow[/b] -mysql_result is basically another form of retrieve results from an SQL Query. I have not used this before so I cant really explain it. Have a read in the manual about it http://php.net/mysql-query
Link to comment
Share on other sites

Oh crap. Another typo of mine.
Change this:
[code]$prodId = isset($_GET['prodId']) && is_numeric($_GET['prodId']) ? $_GET['prodId'] : 'INVALID';

if($prodid == 'INVALID')
{
    die('<h1>Invalid Production Identification</h1>');
}[/code]
to this:
[code]$prodId = isset($_GET['prodId'])) ? $_GET['prodId'] : '0'[/code]
Link to comment
Share on other sites

ok so I changed the code to that

[code]
$prodId = 0;  // wasnt sure if this was to be left in but it doenst seem to make any difference when I take it out

$prodId = isset($_GET['prodId']) ? $_GET['prodId'] : '0'


$sql = "SELECT * FROM product WHERE prodId=$prodId";// line 77
[/code]

now it says

Parse error: parse error, unexpected T_VARIABLE in /home/c/ciaracousins/public_html/admin_update2.php on line 77
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.