Hello Reader,
I'm trying to make an update query that joins 2 fields using PHP, MySql. I can not get it to work for the life of me.
Here is what I came up with.
<?php
require("./connect.inc.php");
connect_db();
$sql = "SELECT * FROM updateproject.updater ORDER BY id";
$query = mysql_query($sql);
$rows = mysql_num_rows($query);
$i=0;
while ($i < $rows) {
$id = mysql_result($query, $i, "ID");
$prtnum = mysql_result($query, $i, "prtnum");
$nomen = mysql_result($query, $i, "nomen");
$fid = mysql_result($query, $id-2, "ID");
$fnomen = mysql_result($query, $id-2, "nomen");
$fprtnum = mysql_result($query, $id-2, "prtnum");
if (!$prtnum <> NULL) {
$fix = "UPDATE updater SET updater.nomen = '$fnomen $nomen'
WHERE (((updater.ID)='$fid'))";
mysql_query($fix);
echo "<p>Process Complete</p>";
}
$i++;
}
?>
And here is what the computer came up with:
Process ComplePHP Warning: mysql_result() [function.mysql-result]: Unable to jump to row 12688 on MySQL result index 3 in c:\Inetpub\wwwroot\UpdaterProject\Merdge.php on line 16 PHP Warning: mysql_result() [function.mysql-result]: Unable to jump to row 12688 on MySQL result index 3 in c:\Inetpub\wwwroot\UpdaterProject\Merdge.php on line 17 PHP Warning: mysql_result() [function.mysql-result]: Unable to jump to row 12689 on MySQL result index 3 in c:\Inetpub\wwwroot\UpdaterProject\Merdge.php on line 16 PHP Warning: mysql_result() [function.mysql-result]: Unable to jump to row 12689 on MySQL result index 3 in c:\Inetpub\wwwroot\UpdaterProject\Merdge.php on line 17 PHP Warning: mysql_result() [function.mysql-result]: Unable to jump to row 12690 on MySQL result index 3 in c:\Inetpub\wwwroot\UpdaterProject\Merdge.php on line 16 PHP Warning: mysql_result() [function.mysql-result]: Unable to jump to row 12690 on MySQL result index 3 in
Any Ideas where I went wrong? It seemed simple enough, but it just won't come together.
Gilbert 😕