Asheeown Posted January 12, 2007 Share Posted January 12, 2007 [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 enteredI'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 More sharing options...
btherl Posted January 12, 2007 Share Posted January 12, 2007 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. Link to comment https://forums.phpfreaks.com/topic/33850-update-scriptnot-updating/#findComment-158854 Share on other sites More sharing options...
DarkendSoul Posted January 12, 2007 Share Posted January 12, 2007 [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] Link to comment https://forums.phpfreaks.com/topic/33850-update-scriptnot-updating/#findComment-158855 Share on other sites More sharing options...
Asheeown Posted January 13, 2007 Author Share Posted January 13, 2007 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? Link to comment https://forums.phpfreaks.com/topic/33850-update-scriptnot-updating/#findComment-159670 Share on other sites More sharing options...
Asheeown Posted January 13, 2007 Author Share Posted January 13, 2007 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] Link to comment https://forums.phpfreaks.com/topic/33850-update-scriptnot-updating/#findComment-159676 Share on other sites More sharing options...
Asheeown Posted January 13, 2007 Author Share Posted January 13, 2007 .... Link to comment https://forums.phpfreaks.com/topic/33850-update-scriptnot-updating/#findComment-159696 Share on other sites More sharing options...
Asheeown Posted January 13, 2007 Author Share Posted January 13, 2007 Absolutely any help would be so much appreciated Link to comment https://forums.phpfreaks.com/topic/33850-update-scriptnot-updating/#findComment-159718 Share on other sites More sharing options...
trq Posted January 13, 2007 Share Posted January 13, 2007 Try btherl's idea and post your results. Link to comment https://forums.phpfreaks.com/topic/33850-update-scriptnot-updating/#findComment-159744 Share on other sites More sharing options...
Asheeown Posted January 13, 2007 Author Share Posted January 13, 2007 [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: 201200Array ( [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 1So I know the npanxx matches with those two rows it's importing a number thats messing up Link to comment https://forums.phpfreaks.com/topic/33850-update-scriptnot-updating/#findComment-159753 Share on other sites More sharing options...
trq Posted January 13, 2007 Share Posted January 13, 2007 Completely lost me there.We need you to print your query. eg;[code=php:0]$sql = "SELECT * FROM blah WHERE foo = '$id'";echo $sql; exit;[/code]Put your query in a variable and print it too the screen for debugging! Link to comment https://forums.phpfreaks.com/topic/33850-update-scriptnot-updating/#findComment-159756 Share on other sites More sharing options...
Asheeown Posted January 13, 2007 Author Share Posted January 13, 2007 [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 Link to comment https://forums.phpfreaks.com/topic/33850-update-scriptnot-updating/#findComment-159761 Share on other sites More sharing options...
trq Posted January 13, 2007 Share Posted January 13, 2007 [code=php:0]$InterUpdateDatabase = mysql_query($Intersql) or die(mysql_error());echo $Intersql; exit;[/code]Is what we wanted but, if your getting a resource id then it meens the query has worked. Link to comment https://forums.phpfreaks.com/topic/33850-update-scriptnot-updating/#findComment-159762 Share on other sites More sharing options...
Asheeown Posted January 13, 2007 Author Share Posted January 13, 2007 I know the query works and I know the update statement works because it uploaded the second column in my update query which was interlcventhis 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? Link to comment https://forums.phpfreaks.com/topic/33850-update-scriptnot-updating/#findComment-159766 Share on other sites More sharing options...
trq Posted January 13, 2007 Share Posted January 13, 2007 What field type is interlc? Link to comment https://forums.phpfreaks.com/topic/33850-update-scriptnot-updating/#findComment-159772 Share on other sites More sharing options...
Asheeown Posted January 13, 2007 Author Share Posted January 13, 2007 Double....but ive tried it as int and varchar Link to comment https://forums.phpfreaks.com/topic/33850-update-scriptnot-updating/#findComment-159774 Share on other sites More sharing options...
trq Posted January 13, 2007 Share Posted January 13, 2007 Im not 100% sure but I think you'd need a FLOAT. You'' also need to adjust its prescision.How many numbers are going to be needed before and after the decimal in total? Link to comment https://forums.phpfreaks.com/topic/33850-update-scriptnot-updating/#findComment-159782 Share on other sites More sharing options...
Asheeown Posted January 13, 2007 Author Share Posted January 13, 2007 At the most 4 places after the decimal and only the zero beforei.e 0.0056 Link to comment https://forums.phpfreaks.com/topic/33850-update-scriptnot-updating/#findComment-159784 Share on other sites More sharing options...
trq Posted January 13, 2007 Share Posted January 13, 2007 Ok, then you need to define the field as... FLOAT(5,4) Link to comment https://forums.phpfreaks.com/topic/33850-update-scriptnot-updating/#findComment-159787 Share on other sites More sharing options...
Asheeown Posted January 13, 2007 Author Share Posted January 13, 2007 thorpe I would hug you but yeah, thanks a lot, works perfectly Link to comment https://forums.phpfreaks.com/topic/33850-update-scriptnot-updating/#findComment-159790 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.