Jump to content


Photo

trying to update fields


  • Please log in to reply
44 replies to this topic

#1 kikilahooch

kikilahooch
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 02 September 2006 - 02:05 PM

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!!

<?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>



#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 02 September 2006 - 03:59 PM

Looks like your query is failing. Change this:
$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>';
			}
To this:
$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>';

You should now get an error returned from MySQL why your query is failing. POst the error you get here.

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 02 September 2006 - 04:02 PM

I thort and i was always told that when you start to hide @ errors then your heading for more problams.

always echo all query's out to see if the data within the query is what it suppose to be good luck.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 kikilahooch

kikilahooch
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 02 September 2006 - 04:19 PM

Thanks, when I did that it said:

Unable to perform query 1

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1

#5 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 02 September 2006 - 04:33 PM

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:
// 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);

So use this instead for $query2:
$query2 = UPDATE product SET prodName='$prodName', dept='$dept', brand='$brand', type='$type', 
image='$image', price='$price' WHERE prodId ='$prodId' and shopName='$shopName'";


#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 02 September 2006 - 04:34 PM

afther all i just done dam didnt see that my self



$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>';
			}
		

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#7 kikilahooch

kikilahooch
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 02 September 2006 - 04:47 PM

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)

$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>';


#8 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 02 September 2006 - 05:06 PM

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.


<?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>


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#9 kikilahooch

kikilahooch
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 02 September 2006 - 05:40 PM

Thanks Redarrow  :)

I did that now. While I was updating it I also noticed that I had my form action wrong. I had it as admin_update.php when it should have been admin_update2.php. Now when I click on an image it no longer displays the table, it just says "query1"

#10 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 02 September 2006 - 05:48 PM

it be better if you echo all the querys out ok.

echo $query1;
under query1

echo $query2;
under query2


echo $query3;
under query3



when you look on the page your see the select staement and this should be the correct order as inteneded so good luck.

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#11 kikilahooch

kikilahooch
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 02 September 2006 - 05:57 PM

ok now it just displays

1query 1

Sorry If I'm being dumb here but really havent a clue of php and have to get this in soon! Really appreciate both your help!

its also still deleting the prodName btw

#12 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 02 September 2006 - 06:06 PM

Try this:
<?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>


#13 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 02 September 2006 - 06:12 PM

give this a quick go ok

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


<?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>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#14 kikilahooch

kikilahooch
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 02 September 2006 - 06:18 PM

Thanks!

Now its says

Unable to perform query2 SELECT * FROM product WHERE prodId = '2' and shopName='savage'

Query was empty

#15 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 02 September 2006 - 06:19 PM

Oops missed typed something Change this line:
$result2 = @mysql_query($query) or die("Unable to perform query2 <code>" . $query2 . "</code><br /><br />" . mysql_error());
to this:
$result2 = @mysql_query($query2) or die("Unable to perform query2 <code>" . $query2 . "</code><br /><br />" . mysql_error());


#16 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 02 September 2006 - 06:20 PM

was that wildteens code or mine with the problam probly me lol...........?
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#17 kikilahooch

kikilahooch
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 02 September 2006 - 06:22 PM

When I tried yours (redarrow) it came up with 1query1,

Wildteens came up with

Unable to perform query2 SELECT * FROM product WHERE prodId = '106' and shopName='savage'

Query was empty

#18 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 02 September 2006 - 06:24 PM

kikilahooch Did you try the correction I suggested in my last post?

Oops missed typed something Change this line:

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



#19 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 02 September 2006 - 06:28 PM

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');
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#20 kikilahooch

kikilahooch
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 02 September 2006 - 06:34 PM

Sorry I just copied and pasted it. I changed it to $query2 now. Its back to saying Updated Successfully and deletes the prodName




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users