Jump to content

Why are the variables from dbs.php not fetched by update.php (below) ?


Recommended Posts

dbs.php:

 

$query2="use $_GET[db]";
$result2=mysql_query($query2);
$sql = "select * from $_GET[t]";
$result2 = mysql_query($sql);
$num=mysql_num_rows($result2);
$r=0;
$c=0;
echo "<form method='get' action='dbs.php'><table border=1><tr>";
for ($b=1; $b<=$num; $b++)
{
$sql2 = "select * from $_GET[t] where id='$b'";
$result4 = mysql_query($sql2);
while ($record = mysql_fetch_assoc($result4)) {
	while (list($fieldname, $fieldvalue) = each ($record)) {
            $c++;
		echo "<td><input type=text id=".$c." value=".$fieldvalue." ; /></td>";
		echo $c;
	}
	echo "</tr>";
	}
	$r++;
}

$table=$_GET["t"];
echo "</table></form><form method='get' action='update.php?c=$c&r=$r&t=$table'>";echo $c." ".$r."<input type=submit name=update value=Update /></form><br />";

 

the variables ($c, $r, $table) i'm sending is in below:

 

echo "</table></form><form method='get' action='update.php?c=$c&r=$r&t=$table'>";echo $c." ".$r."<input type=submit name=update value=Update /></form><br />";

 

 

update.php:

 

<?php
$c=$_GET["c"];
//echo $c;
$r=$_GET["r"];
$t=$_GET["t"];
$d=$c/$r;
$server = mysql_connect('localhost', 'root', '*****') or die(mysql_error());
$db_selected = mysql_select_db($t, $server);
for ($f=1; $f<=$c; $f+=$d)
{
for ($e=1; $e<=$d; $e++)
{
$que.="'abc',";
}
echo $que."<br />";


$queb="insert into ".$t." values (".$que.")";
$quec=mysql_query($queb);
$que="";
echo $queb."<br />";
}
?>

 

 

my output is :

 

Warning: Division by zero in C:\AppServ\www\MySQL Admin\update.php on line 6

If you send form using the get method you should not add variables into the action url.

Try moving variables from action into <input type="hidden" type fields.

  echo "</table></form><form method='get' action='update.php'>";
  echo '<input type="hidden" name="c" value="'.$c.'">';
  echo '<input type="hidden" name="r" value="'.$r.'">';
  echo '<input type="hidden" name="t" value="'.$t.'">';
  echo $c." ".$r."<input type=submit name=update value=Update /></form><br />";

 

Warning appeard because php converts empty variable into 0 (if you deal with such variable in any math operation).

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.