Please help mysql update problem!!
Posted: Tue Jan 27, 2009 12:33 pm
I'm trying to update a mysql database from within a function: the code is as follows:
<?php
function stuff($topic, $zoo){
foreach($paragraphs as $paragraph){
$paragraph = strip_tags($paragraph);
$paragraph = quotemeta($paragraph);
$paragraph = addslashes($paragraph);
if ($paragraph){
$final = $final . $paragraph . "\n\n";
$new_string = substr($final, 0, 2000);
}
}
include ('config.php');
$splitup = explode(',_', $topic);
$City2 = strtoupper($splitup[0]);
$State2 = $splitup[1];
$sql2 = 'UPDATE `zip_codes` SET `City_Desc`="$new_string" WHERE `City`="$City2" AND `State`="$State2" AND `Zip`="$zoo"';
mysql_query($sql2) or die(mysql_error().mysql_errno());
}
?>
There is no problem with the variables getting to the sql statement (i've echoed the variables and they all show up correctly), but for some reason, it just won't insert and there is no error that seems to show up.
I've used the exact same code for the update statement on a different page, and it seems to update the db just fine.
Does anyone know what i'm doing wrong??
<?php
function stuff($topic, $zoo){
foreach($paragraphs as $paragraph){
$paragraph = strip_tags($paragraph);
$paragraph = quotemeta($paragraph);
$paragraph = addslashes($paragraph);
if ($paragraph){
$final = $final . $paragraph . "\n\n";
$new_string = substr($final, 0, 2000);
}
}
include ('config.php');
$splitup = explode(',_', $topic);
$City2 = strtoupper($splitup[0]);
$State2 = $splitup[1];
$sql2 = 'UPDATE `zip_codes` SET `City_Desc`="$new_string" WHERE `City`="$City2" AND `State`="$State2" AND `Zip`="$zoo"';
mysql_query($sql2) or die(mysql_error().mysql_errno());
}
?>
There is no problem with the variables getting to the sql statement (i've echoed the variables and they all show up correctly), but for some reason, it just won't insert and there is no error that seems to show up.
I've used the exact same code for the update statement on a different page, and it seems to update the db just fine.
Does anyone know what i'm doing wrong??