note 55688 added to function.mysql-affected-rows
| From: | yaffalandis at yahoo dot com | Date: | Wed, 10 Aug 2005 16:13:52 +0000 |
| Subject: | note 55688 added to function.mysql-affected-rows | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-93382@lists.php.net to get a copy of this message | ||
when i used the following lines of code what i realized is that my lat/lon fields were being updated
with the same content. why is this?
$link = mysql_connect("localhost", "user", "pass") or die("Could
not connect: " . mysql_error());
mysql_selectdb("db",$link) or die ("Can\'t use server : " . mysql_error());
$query = "SELECT * FROM db";
$result=mysql_query($query);
$num=mysql_numrows($result);
if (!$query) {
die("Could not query:" . mysql_error());
}
$i=0;
while ($i < $num)
{
$address=mysql_result($result,$i,"address");
echo "addy: <b>$address</b><br>";
$query2 = urlencode($address);
echo "encoded addy: <b>$query2</b><br>";
$url = "http://localhost.?address=$query2";
echo "url: <b>$url</b><br>";
$geo = new geoCodeUS;
$geo->getlatlon($query2);
#mysql_query("UPDATE db SET address= '$address' WHERE completed =
'no'") or die ("Insert Error: ".mysql_error());("Insert Error:
".mysql_error());
mysql_query("UPDATE db SET lat= '$geo->lat' WHERE completed =
'no'") or die ("Insert Error: ".mysql_error());("Insert Error:
".mysql_error());
mysql_query("UPDATE db SET lon = '$geo->lon' WHERE completed =
'no'") or die ("Insert Error: ".mysql_error());("Insert Error:
".mysql_error());
mysql_query("UPDATE db SET completed = 'yes' WHERE completed = 'no'")
or die ("Insert Error: ".mysql_error());("Insert Error:
".mysql_error());
$i++;
}
any ideas? please email yaffalandis@yahoo.com
----
Manual Page -- http://www.php.net/manual/en/function.mysql-affected-rows.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55688
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55688&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55688&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55688&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55688&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55688&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55688&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55688&report=yes
Search -- http://master.php.net/manage/user-notes.php