Jump to content

Update Script...Not Updating


Asheeown

Recommended Posts

[code]
UPDATE compare_npanxxcost SET interlc = '$Least' AND interlcven = '$Abbreviation' WHERE npanxx = '$Data[npanxx]'
[/code]

Okay so I tried this two diifferent ways...through php which is like so

[code]
<?php
$UpdateDatabase = mysql_query("UPDATE compare_npanxxcost SET interlc = '.0041' AND interlcven = 'XO' WHERE npanxx = '201200'") or die(mysql_error());
if($UpdateDatabase) {
echo "<center><b>Success<br />".$UpdateDatabase."</b></center>";
echo $Least;
} else {
echo "<center><b>Database Update Failure for NPANXX: $Data[npanxx]<br /></b></center>";
} // End of if($UpdateDatabase)
?>
[/code]

And through plain mysql with the variables manually entered

I'm absolutely positive that these variables are populated and that the query runs through just fine, however when it gets to the database "0 rows affected" everything is correct it doesn't hit errors along the way it just doesn't set the two fields the way they're supposed to be
Link to comment
https://forums.phpfreaks.com/topic/33850-update-scriptnot-updating/
Share on other sites

Try putting the query in a variable, then printing out out, then running the query.  Then you can take a look at the query.

[code=php:0]$sql = "UPDATE ... ";
echo "About to run $sql\n";
$UpdateDatabase = mysql_query($sql) or die(mysql_error());[/code]


If it looks ok and you still get 0 rows affected, try doing a SELECT instead of an UPDATE, to see which rows match the where condition.
[quote]UPDATE compare_npanxxcost SET interlc = '$Least' AND interlcven = '$Abbreviation' WHERE npanxx = '$Data[npanxx]'[/quote]

SET does not use "AND" instead you list the items you want to change as such.

[quote]UPDATE compare_npanxxcost SET interlc = '$Least', interlcven = '$Abbreviation' WHERE npanxx = '$Data[npanxx]'[/quote]
It got "interlcven" to upload the Abbrv. but the "interlc" is supposed to update a number for example: "0.041" is the first of the rows that gets updated, instead of "0.041" it inputs 1 and I'm positive that $Least = "0.041" when $Least doesn't have a value the value in the database is "0"


Any thoughts?
BTW This is the update code now

[code]                      $Intersql = "UPDATE compare_npanxxcost SET interlc = '$InterLC', interlcven = '$InterCarrier[Abbreviation]' WHERE npanxx = '$Data[npanxx]'";
$InterUpdateDatabase = mysql_query($Intersql) or die(mysql_error());
if($InterUpdateDatabase) {
echo "<center><b>Inter Update Success for NPANXX: $Data[npanxx]<br /></b></center>";
} else {
echo "<center><b><font color=\"FF0000\">Database Update Failure for NPANXX: $Data[npanxx]</font><br /></b></center>";
} // End of if($UpdateDatabase)[/code]
[quote]Array ( [NPA] => [NXX] => [npanxx] => 201200 [lata] => 224 [ocn] => 9206 [lataocn] => 2249206 [state] => NJ [lower48] => [xoocntype] => RBOC [pbocntype] => RBOC [RBOCcode] => 1 [inter1] => 0.0155 [inter2] => 0.0065 [inter3] => 0.0084 [inter4] => 0.0054 [inter5] => 0.0084 [inter6] => 0.0051 [inter7] => 0.0041 [inter8] => 0.0097 [inter9] => 0.0115 [inter10] => 0.008 [inter11] => 0.0051 [inter12] => 0.0053 [intermarg] => 0 [interlc] => 1 [interlcven] => XO [interlc2] => 1 [interlcven2] => L3 [interavg] => 0.0046 [intra1] => 0.0155 [intra2] => 0.0065 [intra3] => 0.0147 [intra4] => 0.00966 [intra5] => 99.9999 [intra6] => 0.0117 [intra7] => 0.0041 [intra8] => 99.9999 [intra9] => 0.0115 [intra10] => 0.008 [intra11] => 99.9999 [intra12] => 0.0361 [intramarg] => 0 [intralc] => 0.0041 [intralcven] => [intraavg] => 0.0114 ) for NPANXX: 201200
Array ( [NPA] => [NXX] => [npanxx] => 201202 [lata] => 224 [ocn] => 6630 [lataocn] => 2246630 [state] => NJ [lower48] => [xoocntype] => MOBL [pbocntype] => NECA [RBOCcode] => 0 [inter1] => 0.0155 [inter2] => 0.0065 [inter3] => 0.0071 [inter4] => 0.005 [inter5] => 0.0064 [inter6] => 0.0155 [inter7] => 0.0066 [inter8] => 0.0061 [inter9] => 0.0115 [inter10] => 0.008 [inter11] => 0.0069 [inter12] => 0.0052 [intermarg] => 0 [interlc] => 0 [interlcven] => QW [interlc2] => 0 [interlcven2] => BB [interavg] => 0.00655 [intra1] => 0.0155 [intra2] => 0.0065 [intra3] => 0.0076 [intra4] => 0.0104 [intra5] => 99.9999 [intra6] => 0.0328 [intra7] => 0.0066 [intra8] => 99.9999 [intra9] => 0.0115 [intra10] => 0.008 [intra11] => 99.9999 [intra12] => 0.0756 [intramarg] => 0 [intralc] => 0.0065 [intralcven] => [intraavg] => 0.0127 )[/quote]

That would be my result however the part we really want is

[quote][interlc] => 1 [interlcven] => XO[/quote]

Now interlc when it updates either gets a 0 for when the variable is not set and a 1 when it is set...only problem is i'm telling it to import the number 0.041 to it on this particular one but it came up 1

So I know the npanxx matches with those two rows it's importing a number thats messing up
[code]
$InterUpdateDatabase = mysql_query($Intersql) or die(mysql_error());
if($InterUpdateDatabase) {
echo "<center><b>";
echo $InterUpdateDatabase;
echo " for NPANXX: $Data[npanxx]<br /></b></center>";
} else {
echo "<center><b><font color=\"FF0000\">Database Update Failure for NPANXX: $Data[npanxx]</font><br /></b></center>";
} // End of if($UpdateDatabase)[/code]

Okay work with me here I just modified my old script to this for now...now this returns a resource ID# and my added feature for the npanxxx which for right now you can think of as the ID.

[quote]Resource id #7 for NPANXX: 201200[/quote]
Thats how it came out
I know the query works and I know the update statement works because it uploaded the second column in my update query which was interlcven

this data being inputted for interlc is a number is their any thing that needs to be done to say the update query that says specifically that that column is a number or not?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.