Jump to content

Recommended Posts

I am trying to add a value to a field in a table WHERE To otehr values of that field match.

 

something like

 

$query  = "INSERT (visitor_whois) VALUES ( '$ip_info') INTO visitor_list WHERE visitor_day  = '$today' and visitor_month  = '$month'";


$result = mysql_query($query) or trigger_error(mysql_error(),E_USER_ERROR);

 

but I am getting an error that is not helping me. Any ideas

Link to comment
https://forums.phpfreaks.com/topic/158802-insert-into-where/
Share on other sites

I got the UPDATE to work. now I am having issues with mysql_fetch_array

 

$query  = "SELECT * FROM visitor_list WHERE visitor_day  = '$today' and visitor_month  = '$month'";
$result = mysql_query($query)or die (mysql_error());
            while($row = mysql_fetch_array($result, MYSQL_ASSOC)){

             $string = file_get_contents("http://www.websitehere.com/soap/client-example-city.php?ip={$row['visitor_ip']}");

echo $string;

 

I am trying to send the vaule of $row['visitor_ip'] on the end of the url is this the best way to do it?

 

Link to comment
https://forums.phpfreaks.com/topic/158802-insert-into-where/#findComment-837576
Share on other sites

That usually means your query is failing, but it's syntactically correct.  You do have some spacing issues.  Right before your '=' you have 2 spaces, should be one, but this wouldn't throw this warning.

 

You don't get an error output for: ?

 

$result = mysql_query($query)or die (mysql_error());

Link to comment
https://forums.phpfreaks.com/topic/158802-insert-into-where/#findComment-837599
Share on other sites

so my while statement is working but for some reason the variable {$row['visitor_ip']}  is not changing which it should since it is different in every row.  Any thoughts?  here is my full code:

 

ini_set("display_errors","2");
ERROR_REPORTING(E_ALL);

require_once('visitors_connections.php');//the file with connection code and functions
//get the required data
$today= date("d");
$month= date("m");

mysql_select_db($database_visitors, $visitors);

$query  = "SELECT * FROM visitor_list WHERE visitor_day  = '$today' and visitor_month  = '$month'";
$result = mysql_query($query)or die (mysql_error());

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{

$website = "http://www.websitehere.com/soap/client-example-city.php?ip{$row['visitor_ip']}";
echo $website;
$string = file_get_contents($website);

if (strpos($string,"org")){


$orginfo = explode("org", $string);

$city = $orginfo[1];

$output = explode('"',$city); 

$ip_info = $output[2];

}else {
$ip_info = 'I was unable to find data on this IP';
}

$ip_info = mysql_real_escape_string($ip_info);

$query  = "UPDATE visitor_list SET visitor_whois = '$ip_info' WHERE visitor_day  = '$today' and visitor_month  = '$month'";

$result = mysql_query($query) or trigger_error(mysql_error(),E_USER_ERROR);

}

Link to comment
https://forums.phpfreaks.com/topic/158802-insert-into-where/#findComment-837603
Share on other sites

when I add

$query = "SELECT visitor_ip FROM visitor_list WHERE visitor_day  = '$today' and visitor_month  = '$month'";
$result = mysql_query($query)or die (mysql_error());
print_r(mysql_fetch_assoc($result));

 

it is only getting one IP address there should be like 2o rows that all have the same day and month all with different visitor_ip entries.  I need to run a for loop for everyone of those different ip's

Link to comment
https://forums.phpfreaks.com/topic/158802-insert-into-where/#findComment-837633
Share on other sites

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.