Forum Moderators: coopster
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Statistial Analysis</title>
</head>
<body>
<form action="valuechange.php?todo=1" method="post">
<table border="0" align="center" width="100%">
<tr>
<td>
Enter localhost String<input type="text" name="lcl" />
</td>
</tr>
<tr>
<td>
Enter User Name<input type="text" name="usr" />
</td>
</tr>
<tr>
<td>
Enter Password Name<input type="text" name="pass" />
</td>
</tr>
<tr>
<td>
Enter Databse Name<input type="text" name="dbnm" />
</td>
</tr>
<tr>
<td>
Enter Table Name<input type="text" name="tblnm" />
</td>
</tr>
<tr>
<td>
Enter Priamary Key Name<input type="text" name="pmnm" />
</td>
</tr>
<tr>
<td>
Enter Column Name<input type="text" name="clmnm" />
</td>
</tr>
<tr>
<td>
Enter Initial Value<input type="text" name="inv" />
</td>
<td>
Enter Final Value<input type="text" name="fnv" />
</td>
</tr>
<tr>
<td>
<input type="submit" value="Do" />
</td>
</tr>
</table>
</form>
<?php
if($_GET['todo'] == 1)
{
// Connecting with Server
$conn = mysql_connect($_POST['lcl'],$_POST['usr'],$_POST['pass']) or die(mysql_error());
// Conncting with Database
mysql_select_db($_POST['dbnm'], $conn) or die(mysql_error());
$cnt = 0;
$read = "select * from `".$_POST['tblnm']."`";
$res=mysql_query($read, $conn);
if(mysql_num_rows($res)<1 )
{
}
else
{
while($read1=mysql_fetch_array($res))
{
$val=rand($_POST['inv'],$_POST['fnv']);
$update = "UPDATE `".$_POST['tblnm']."` SET `".$_POST['clmnm']."` = '".$val."' WHERE `".$_POST['pmnm']."` = '".$read1['$_POST[pmnm]']."'";
if(mysql_query($update, $conn))
{
$cnt++;
}
else
{
die(mysql_error());
}
}
}
}
echo $cnt." Accounts Updated <br>";
?>
</body>
</html>
instead of actually sending your queries just output them, it might help you see what is going on
maybe something like
while($read1=mysql_fetch_array($res)) {
$val=rand($_POST['inv'],$_POST['fnv']);
$update = "UPDATE `".$_POST['tblnm']."` SET `".$_POST['clmnm']."` = '".$val."' WHERE `".$_POST['pmnm']."` = '".$read1['$_POST[pmnm]']."'";
//if(mysql_query($update, $conn)) $cnt++;
//else die(mysql_error());
$cnt++;
echo '<br>query #',$cnt,': ",$update;
}
I compressed your code a bit and added some testing lines
query #2: "UPDATE `auctionbidz_auctionmanagment` SET `auction_duration` = '3' WHERE `auction_id` = ''
query #3: "UPDATE `auctionbidz_auctionmanagment` SET `auction_duration` = '3' WHERE `auction_id` = ''
query #4: "UPDATE `auctionbidz_auctionmanagment` SET `auction_duration` = '3' WHERE `auction_id` = ''
query #5: "UPDATE `auctionbidz_auctionmanagment` SET `auction_duration` = '1' WHERE `auction_id` = ''
query #6: "UPDATE `auctionbidz_auctionmanagment` SET `auction_duration` = '2' WHERE `auction_id` = ''
query #7: "UPDATE `auctionbidz_auctionmanagment` SET `auction_duration` = '1' WHERE `auction_id` = ''
query #8: "UPDATE `auctionbidz_auctionmanagment` SET `auction_duration` = '1' WHERE `auction_id` = ''
query #9: "UPDATE `auctionbidz_auctionmanagment` SET `auction_duration` = '2' WHERE `auction_id` = ''
[edited by: eelixduppy at 6:35 pm (utc) on May 9, 2008]
[edit reason] snipped excess code [/edit]
when you look at those queries there is no auction_id in any of them
that would mean that this
$read1['$_POST[pmnm]']
isn't resolving properly, now that I look at it that isn't much of a surprise
maybe
$read1[{$_POST[pmnm]}]
or
$r1 = $_POST[pmnm];
$read1[$r1]