I inherited this code and I can ot get it to INSERT into the first table "property_tbl"
The upload, resize and INSERT of the image part works fine.
But I am not getting any errors. And I have been staring at it for days now.
<?php
session_start();
if(empty($_SESSION[ss_user_id])){
$header("Location: login.php");
}
include_once("includes/config.inc.php");
include_once("includes/function.inc.php");
$pro_type_id = $_REQUEST["pro_type_id"];
$pro_sid = $_REQUEST["pro_sid"];
$pro_name = $_REQUEST["pro_name"];
$pro_name_jp = $_REQUEST["pro_name_jp"];
$pro_title = $_REQUEST["pro_title"];
$pro_title_jp = $_REQUEST["pro_title_jp"];
$pro_desc = htmlentities($_REQUEST["pro_desc"],ENT_QUOTES);
$pro_desc_jp = htmlentities($_REQUEST["pro_desc_jp"],ENT_QUOTES);
$pro_notes = $_REQUEST["pro_notes"];
$pro_notes_jp = $_REQUEST["pro_notes_jp"];
$pro_address = $_REQUEST["pro_address"];
$pro_address_jp = $_REQUEST["pro_address_jp"];
$pro_email = $_REQUEST["pro_email"];
$pro_email_jp = $_REQUEST["pro_email_jp"];
$pro_contact = $_REQUEST["pro_contact"];
$pro_contact_jp = $_REQUEST["pro_contact_jp"];
$pro_price_low = $_REQUEST["pro_price_low"];
$pro_price_rent_high = $_REQUEST["pro_price_rent_high"];
$pro_price_rent_long = $_REQUEST["pro_price_rent_long"];
$pro_size_ext = $_REQUEST["pro_size_ext"];
$pro_ownership = $_REQUEST["pro_ownership"];
$pro_ownership_jp = $_REQUEST["pro_ownership_jp"];
$pro_house_stands = $_REQUEST["pro_house_stands"];
$pro_house_stands_jp = $_REQUEST["pro_house_stands_jp"];
$pro_years_left = $_REQUEST["pro_years_left"];
$pro_house = $_REQUEST["pro_house"];
$pro_house_jp = $_REQUEST["pro_house_jp"];
$pro_years_left_house = $_REQUEST["pro_years_left_house"];
$pro_common = $_REQUEST["pro_common"];
$pro_common_jp = $_REQUEST["pro_common_jp"];
$pro_price = $_REQUEST["pro_price"];
$pro_price_rent = $_REQUEST["pro_price_rent"];
$pro_price_rai = $_REQUEST["pro_price_rai"];
$size_land_rai = $_REQUEST["size_land_rai"];
$size_land_ngan = $_REQUEST["size_land_ngan"];
$size_land_wah = $_REQUEST["size_land_wah"];
$pro_bed = $_REQUEST["pro_bed"];
$pro_bath = $_REQUEST["pro_bath"];
$pro_land = $_REQUEST["pro_land"];
$pro_size = $_REQUEST["pro_size"];
$pro_view = $_REQUEST["pro_view"];
$pro_view_jp = $_REQUEST["pro_view_jp"];
$pro_furnished = $_REQUEST["pro_furnished"];
$pro_furnished_jp = $_REQUEST["pro_furnished_jp"];
$pro_furniture = $_REQUEST["pro_furniture"];
$pro_furniture_jp = $_REQUEST["pro_furniture_jp"];
$pro_kitchen = $_REQUEST["pro_kitchen"];
$pro_kitchen_jp = $_REQUEST["pro_kitchen_jp"];
$pro_internet = $_REQUEST["pro_internet"];
$pro_internet_jp = $_REQUEST["pro_internet_jp"];
$pro_aircon = $_REQUEST["pro_aircon"];
$pro_aircon_jp = $_REQUEST["pro_aircon_jp"];
$pro_pool = $_REQUEST["pro_pool"];
$pro_pool_jp = $_REQUEST["pro_pool_jp"];
$pro_parking = $_REQUEST["pro_parking"];
$pro_parking_jp = $_REQUEST["pro_parking_jp"];
$pro_distancetown = $_REQUEST["pro_distancetown"];
$pro_distancebeach = $_REQUEST["pro_distancebeach"];
$pro_features = $_REQUEST["pro_features"];
$pro_features_jp = $_REQUEST["pro_features_jp"];
$pro_loc = $_REQUEST["pro_loc"];
$pro_loc_jp = $_REQUEST["pro_loc_jp"];
$pro_status = $_REQUEST["pro_status"];
$pro_reccom = $_REQUEST["pro_reccom"];
$query = "INSERT INTO property_tbl SET
pro_type_id = '$pro_type_id',
pro_sid = '$pro_sid',
pro_name = '$pro_name',
pro_name_jp = '$pro_name_jp',
pro_title = '$pro_title',
pro_title_jp = '$pro_title_jp',
pro_desc = '$pro_desc',
pro_desc_jp = '$pro_desc_jp',
pro_notes = '$pro_notes',
pro_notes_jp = '$pro_notes_jp',
pro_address = '$pro_address',
pro_address_jp = '$pro_address_jp',
pro_email = '$pro_email',
pro_email_jp = '$pro_email_jp',
pro_contact = '$pro_contact',
pro_contact_jp = '$pro_contact_jp',
pro_price_low = '$pro_price_low',
pro_price_rent_high = '$pro_price_rent_high',
pro_price_rent_long = '$pro_price_rent_long',
pro_size_ext = '$pro_size_ext',
pro_ownership = '$pro_ownership',
pro_ownership_jp = '$pro_ownership_jp',
pro_house_stands = '$pro_house_stands',
pro_house_stands_jp = '$pro_house_stands_jp',
pro_years_left = '$pro_years_left',
pro_house = '$pro_house',
pro_house_jp = '$pro_house_jp',
pro_years_left_house = '$pro_years_left_house',
pro_common = '$pro_common',
pro_common_jp = '$pro_common_jp',
pro_price = '$pro_price',
pro_price_rent = '$pro_price_rent',
pro_price_rai = '$pro_price_rai',
size_land_rai = '$size_land_rai',
size_land_ngan = '$size_land_ngan',
size_land_wah = '$size_land_wah',
pro_bed = '$pro_bed',
pro_bath = '$pro_bath',
pro_land = '$pro_land',
pro_size = '$pro_size',
pro_view = '$pro_view',
pro_view_jp = '$pro_view_jp',
pro_furnished = '$pro_furnished',
pro_furnished_jp = '$pro_furnished_jp',
pro_furniture = '$pro_furniture',
pro_furniture_jp = '$pro_furniture_jp',
pro_kitchen = '$pro_kitchen',
pro_kitchen_jp = '$pro_kitchen_jp',
pro_internet = '$pro_internet',
pro_internet_jp = '$pro_internet_jp'
pro_aircon = '$pro_aircon',
pro_aircon_jp = '$pro_aircon_jp',
pro_pool = '$pro_pool',
pro_pool_jp = '$pro_pool_jp',
pro_parking = '$pro_parking',
pro_parking_jp = '$pro_parking_jp',
pro_distancetown = '$pro_distancetown',
pro_distancebeach = '$pro_distancebeach',
pro_features = '$pro_features',
pro_features_jp = '$pro_features_jp',
pro_loc = '$pro_loc',
pro_loc_jp = '$pro_loc_jp',
pro_status = '$pro_status',
pro_reccom = '$pro_reccom',
pro_adddate = '$date_now',
pro_addby = '$_SESSION[ss_user_id]'";
mysql_query($query);
echo "<br /><br />".$query;
$sql = "SELECT * FROM property_tbl ORDER BY pro_id DESC LIMIT 1";
$result = mysql_query($sql);
$line = mysql_fetch_array($result, MYSQL_ASSOC);
$NewId = $line["pro_id"];
foreach ($_FILES["pictures"]["error"] as $key => $error){
if($error == UPLOAD_ERR_OK){
$uploads_normal = '../images/pro-photo/normals';
$uploads_thumb = '../images/pro-photo/thumbnails';
$tmp_name = $_FILES["pictures"]["tmp_name"][$key];
$pic_name = $_FILES["pictures"]["name"][$key];
$ext = strtolower(end(explode('.',$pic_name)));
$imgname = $nextId.md5(rand() * time()).".".$ext;
/* resize normal photo*/
$width1=800;
$size1=GetimageSize($tmp_name);
$height1=round($width1*$size1[1]/$size1[0]);
if($ext == "jpg" or $ext=="jpeg"){
$images_orig1 = ImageCreateFromJPEG($tmp_name);
}elseif($ext =="png"){
$images_orig1 = ImageCreateFromPNG($tmp_name);
}elseif($ext =="gif"){
$images_orig1 = ImageCreateFromGIF($tmp_name);
}
$photoX1 = ImagesX($images_orig1);
$photoY1 = ImagesY($images_orig1);
$images_fin1 = ImageCreateTrueColor($width1, $height1);
ImageCopyResampled($images_fin1, $images_orig1, 0, 0, 0, 0, $width1+1, $height1+1, $photoX1, $photoY1);
if ($ext == "jpg" or $ext == "jpeg"){
ImageJPEG($images_fin1,"$uploads_normal/".$imgname);
}elseif($ext == "png"){
ImagePNG($images_fin1,"$uploads_normal/".$imgname);
}elseif($ext == "gif"){
ImageGIF($images_fin1,"$uploads_normal/".$imgname);
}
ImageDestroy($images_orig1);
ImageDestroy($images_fin1);
$width=303;
$size=GetimageSize($tmp_name);
$height=round($width*$size[1]/$size[0]);
if($ext == "jpg" or $ext=="jpeg"){
$images_orig = ImageCreateFromJPEG($tmp_name);
}elseif($ext =="png"){
$images_orig = ImageCreateFromPNG($tmp_name);
}elseif($ext =="gif"){
$images_orig = ImageCreateFromGIF($tmp_name);
}
$photoX = ImagesX($images_orig);
$photoY = ImagesY($images_orig);
$images_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY);
if ($ext == "jpg" or $ext == "jpeg"){
ImageJPEG($images_fin,"$uploads_thumb/".$imgname);
}elseif($ext == "png"){
ImagePNG($images_fin,"$uploads_thumb/".$imgname);
}elseif($ext == "gif"){
ImageGIF($images_fin,"$uploads_thumb/".$imgname);
}
ImageDestroy($images_orig);
ImageDestroy($images_fin);
$sql_img = "INSERT INTO pro_img (img_id, pro_id, img_name) VALUES ('', '$NewId', '$imgname')";
if(mysql_query($sql_img)){
// print "<script language='javascript'>alert('Add Property complete.');</script>";
// print "<meta http-equiv='refresh' content='0;URL=index.php'>";
}
}
}
print "<script language='javascript'>alert('Add Property complete.');</script>";
print "<meta http-equiv='refresh' content='0;URL=index.php'>";
?>
config.inc.php is just the database connection, which works fine.
Any help would be great.
Thank you
I would echo the query and try it in sequel pro, you probably have misspelt some table names.
Also I would never type all this code, instead foreach over $REQUEST and append it to the query
$query = "INSERT INTO property_tbl SET";
foreach($REQUEST as $key => $value) {
$query .= $key . "= '". $value."',";
}
and delete the comma after the loop :)
Thanks for your ideas. But it turns out that staring at it did work eventually.
The problem was a missing comma after $pro_internet_jp
pro_internet = '$pro_internet',
pro_internet_jp = '$pro_internet_jp'
pro_aircon = '$pro_aircon',
All working fine now.
Thanks
Related
I currently have a site that uploads a CSV and displays it in a preview table as a form that can be edited (if any CSV values are wrong).
It works great, but I need to insert this into a database table with any edits that are made within the form. I have an array that puts the uploaded CSV into this form, but now I think I need to create a new CSV from this form and submit THAT CSV into the database. I've seen some tutorials but I'm unclear on how to do it from this table/form.
Here is the code for the existing preview form:
if(isset($_POST['preview']))
{
ini_set('auto_detect_line_endings', true);
$file = $_FILES["file"]["tmp_name"];
$handle = fopen($file, "r");
$maxPreviewRows = PHP_INT_MAX; // this will be ~2 billion on 32-bit system, or ~9 quintillion on 64-bit system
$hasHeaderRow = true;
?><form><?
echo '<table>';
/*WE WILL NEED TO QA CONDITIONS AND HIGHLIGHT IN RED HERE. ALSO NEED BORDER STYLINGS*/
if ($hasHeaderRow) {
$headerRow = fgetcsv($handle);
echo '<thead><tr>';
foreach($headerRow as $value) {
echo "<th>$value</th>";
}
echo '</tr></thead>';
}
echo '<tbody>';
$rowCount = 0;
while ($row = fgetcsv($handle)) {
echo '<tr>';
foreach($row as $value) {
echo "<td>$value</td>";
}
echo '</tr>';
if (++$rowCount > $maxPreviewRows) {
break;
}
}
echo '</tbody></table>';
}
?></form>
Since this doesn't have values for each field in the form, I'm unsure of the best way to create a CSV from this and insert it into my staging table.
UPDATE - the below code is my first attempt at using my CSV upload array
if(isset($_POST['submit']))
{
$file = $_FILES["file"]["tmp_name"];
$handle = fopen($file, "r");
$filesop = fgetcsv($handle, 0, ",");
while (($filesop = fgetcsv($handle)) !== FALSE) {
$coldata = array();
$coldata["orderNumber"] = $filesop[0];
$coldata["workOrderPacket"] = $filesop[1];
$coldata["workOrderNum"] = $filesop[2];
$coldata["lowSideMIUNumArriv"] = $filesop[3];
$coldata["lowSideMIUNumDepart"] = $filesop[4];
$coldata["highSideMIUNumArriv"] = $filesop[5];
$coldata["highSideMIUNumDepart"] = $filesop[6];
$coldata["accountNum"] = $filesop[7];
$coldata["filler1"] = $filesop[8];
$coldata["address"] = $filesop[9];
$coldata["filler2"] = $filesop[10];
$coldata["date"] = $filesop[11];
$coldata["utility"] = $filesop[12];
$coldata["serialNumber"] = $filesop[13];
$coldata["serviceName"] = $filesop[14];
$coldata["locationNotes"] = $filesop[15];
$coldata["locationComments"] = $filesop[16];
$coldata["filler3"] = $filesop[17];
$coldata["WaterValveArriv"] = $filesop[18];
$coldata["WaterValveDepart"] = $filesop[19];
$coldata["meterSize"] = $filesop[20];
$coldata["meterType"] = $filesop[21];
$coldata["manufacturer"] = $filesop[22];
$coldata["registration"] = $filesop[23];
$coldata["technician"] = $filesop[24];
$coldata["linePressurePSI"] = $filesop[25];
$coldata["filler4"] = $filesop[26];
$coldata["filler5"] = $filesop[27];
$coldata["lowSideRrBefore"] = $filesop[28];
$coldata["highSideRrBefore"] = $filesop[29];
$coldata["lowSideRrAfter"] = $filesop[30];
$coldata["highSideRrAfter"] = $filesop[31];
$coldata["vgOxygen"] = $filesop[32];
$coldata["vgCombustGas"] = $filesop[33];
$coldata["vgCarbonMon"] = $filesop[34];
$coldata["vgHydroSulf"] = $filesop[35];
$coldata["test1TestRateGPM"] = $filesop[36];
$coldata["test1MeterVol"] = $filesop[37];
$coldata["test1TesterVol"] = $filesop[38];
$coldata["test1Accuracy"] = $filesop[39];
$coldata["test1CorrectAcc"] = $filesop[40];
$coldata["test2TestRateGPM"] = $filesop[41];
$coldata["test2MeterVol"] = $filesop[42];
$coldata["test2TesterVol"] = $filesop[43];
$coldata["test2Accuracy"] = $filesop[44];
$coldata["test2CorrectAcc"] = $filesop[45];
$coldata["test3TestRateGPM"] = $filesop[46];
$coldata["test3MeterVol"] = $filesop[47];
$coldata["test3TesterVol"] = $filesop[48];
$coldata["test3Accuracy"] = $filesop[49];
$coldata["test3CorrectAcc"] = $filesop[50];
$coldata["test4TestRateGPM"] = $filesop[51];
$coldata["test4MeterVol"] = $filesop[52];
$coldata["test4TesterVol"] = $filesop[53];
$coldata["test4Accuracy"] = $filesop[54];
$coldata["test4CorrectAcc"] = $filesop[55];
$coldata["test5TestRateGPM"] = $filesop[56];
$coldata["test5MeterVol"] = $filesop[57];
$coldata["test5TesterVol"] = $filesop[58];
$coldata["test5Accuracy"] = $filesop[59];
$coldata["test5CorrectAcc"] = $filesop[60];
$coldata["test6TestRateGPM"] = $filesop[61];
$coldata["test6MeterVol"] = $filesop[62];
$coldata["test6TesterVol"] = $filesop[63];
$coldata["test6Accuracy"] = $filesop[64];
$coldata["test6CorrectAcc"] = $filesop[65];
$coldata["test7TestRateGPM"] = $filesop[66];
$coldata["test7MeterVol"] = $filesop[67];
$coldata["test7TesterVol"] = $filesop[68];
$coldata["test7Accuracy"] = $filesop[69];
$coldata["test7CorrectAcc"] = $filesop[70];
$coldata["test8TestRateGPM"] = $filesop[71];
$coldata["test8MeterVol"] = $filesop[72];
$coldata["test8TesterVol"] = $filesop[73];
$coldata["test8Accuracy"] = $filesop[74];
$coldata["test8CorrectAcc"] = $filesop[75];
$coldata["inletValveLoc"] = $filesop[76];
$coldata["inletValveSize"] = $filesop[77];
$coldata["InletValveType"] = $filesop[78];
$coldata["inletValveCond"] = $filesop[79];
$coldata["outletValveLoc"] = $filesop[80];
$coldata["outletValveSize"] = $filesop[81];
$coldata["outletValveType"] = $filesop[82];
$coldata["outletValveCond"] = $filesop[83];
$coldata["bypassValveLoc"] = $filesop[84];
$coldata["bypassValveSize"] = $filesop[85];
$coldata["bypassValveType"] = $filesop[86];
$coldata["bypassValveCond"] = $filesop[87];
$coldata["vaultLength"] = $filesop[88];
$coldata["vaultWidth"] = $filesop[89];
$coldata["vaultHeight"] = $filesop[90];
$coldata["meterLocation"] = $filesop[91];
$coldata["testPort"] = $filesop[92];
$coldata["testPortInstalled"] = $filesop[93];
$coldata["testPortSize"] = $filesop[94];
$coldata["picture"] = $filesop[95];
$coldata["timeTested"] = $filesop[96];
$coldata["comments"] = $filesop[97];
$coldata["testResults"] = $filesop[98];
$coldata["retest"] = $filesop[99];
$coldata["test1TestRateGPM2"] = $filesop[100];
$coldata["test1MeterVol2"] = $filesop[101];
$coldata["test1TesterVol2"] = $filesop[102];
$coldata["test1Accuracy2"] = $filesop[103];
$coldata["test1CorrectAcc2"] = $filesop[104];
$coldata["test2TestRateGPM2"] = $filesop[105];
$coldata["test2MeterVol2"] = $filesop[106];
$coldata["test2TesterVol2"] = $filesop[107];
$coldata["test2Accuracy2"] = $filesop[108];
$coldata["test2CorrectAcc2"] = $filesop[109];
$coldata["test3TestRateGPM2"] = $filesop[110];
$coldata["test3MeterVol2"] = $filesop[111];
$coldata["test3TesterVol2"] = $filesop[112];
$coldata["test3Accuracy2"] = $filesop[113];
$coldata["test3CorrectAcc2"] = $filesop[114];
$coldata["test4TestRateGPM2"] = $filesop[115];
$coldata["test4MeterVol2"] = $filesop[116];
$coldata["test4TesterVol2"] = $filesop[117];
$coldata["test4Accuracy2"] = $filesop[118];
$coldata["test4CorrectAcc2"] = $filesop[119];
$coldata["test5TestRateGPM2"] = $filesop[120];
$coldata["test5MeterVol2"] = $filesop[121];
$coldata["test5TesterVol2"] = $filesop[122];
$coldata["test5Accuracy2"] = $filesop[123];
$coldata["test5CorrectAcc2"] = $filesop[124];
$coldata["test6TestRateGPM2"] = $filesop[125];
$coldata["test6MeterVol2"] = $filesop[126];
$coldata["test6TesterVol2"] = $filesop[127];
$coldata["test6Accuracy2"] = $filesop[128];
$coldata["test6CorrectAcc2"] = $filesop[129];
$coldata["test7TestRateGPM2"] = $filesop[130];
$coldata["test7MeterVol2"] = $filesop[131];
$coldata["test7TesterVol2"] = $filesop[132];
$coldata["test7Accuracy2"] = $filesop[133];
$coldata["test7CorrectAcc2"] = $filesop[134];
$coldata["test8TestRateGPM2"] = $filesop[135];
$coldata["test8MeterVol2"] = $filesop[136];
$coldata["test8TesterVol2"] = $filesop[137];
$coldata["test8Accuracy2"] = $filesop[138];
$coldata["test8CorrectAcc2"] = $filesop[139];
$coldata["filler6"] = $filesop[140];
$coldata["filler7"] = $filesop[141];
$coldata["filler8"] = $filesop[142];
$coldata["filler9"] = $filesop[143];
$coldata["filler10"] = $filesop[144];
$coldata["filler11"] = $filesop[145];
$coldata["filler12"] = $filesop[146];
$coldata["serviceAddCorrect"] = $filesop[147];
$coldata["serviceLoccCorrect"] = $filesop[148];
$coldata["meterNumberCorrect"] = $filesop[149];
$coldata["lowRegisterCorrect"] = $filesop[150];
$coldata["lowRegisterType"] = $filesop[151];
$coldata["lowRegisterSize"] = $filesop[152];
$coldata["highRegisterCorrect"] = $filesop[153];
$coldata["highRegisterSize"] = $filesop[154];
$coldata["highRegisterType"] = $filesop[155];
$coldata["meterLidType"] = $filesop[156];
$coldata["meterLidMaterial"] = $filesop[157];
$coldata["lidFit"] = $filesop[158];
$coldata["lidCondition"] = $filesop[159];
$coldata["antennaeMountCor"] = $filesop[160];
$coldata["antennaePosition"] = $filesop[161];
$coldata["registerCondition"] = $filesop[162];
$coldata["MIUwire"] = $filesop[163];
$coldata["registerPinArriv"] = $filesop[164];
$coldata["registerPinDepart"] = $filesop[165];
$coldata["vaultType"] = $filesop[166];
$coldata["vaultSafe"] = $filesop[167];
$coldata["vaultLadder"] = $filesop[168];
$coldata["workOrderType"] = $filesop[169];
$coldata["workOrderLocation"] = $filesop[170];
$coldata["completeMeter"] = $filesop[171];
$coldata["ume"] = $filesop[172];
$coldata["discChamber"] = $filesop[173];
$coldata["turbineChamber"] = $filesop[174];
$coldata["automaticValve"] = $filesop[175];
$coldata["strainer"] = $filesop[176];
$coldata["lowRegister"] = $filesop[177];
$coldata["highRegister"] = $filesop[178];
$coldata["miu"] = $filesop[179];
$coldata["antennae"] = $filesop[180];
$coldata["calibrationVane"] = $filesop[181];
$coldata["meterLeakRepaired"] = $filesop[182];
$coldata["workOrderType2"] = $filesop[183];
$coldata["strainerPresent"] = $filesop[184];
$coldata["apparentLeak"] = $filesop[185];
$coldata["leakLocation"] = $filesop[186];
$coldata["leakType"] = $filesop[187];
$coldata["locateBypassValve"] = $filesop[188];
$coldata["locateInletValve"] = $filesop[189];
$coldata["locateOutletValve"] = $filesop[190];
$coldata["PreformShutdown"] = $filesop[191];
$coldata["turnOnWater"] = $filesop[192];
$coldata["repairLid"] = $filesop[193];
$coldata["repairVault"] = $filesop[194];
$coldata["repairLadder"] = $filesop[195];
$coldata["repairLeak"] = $filesop[196];
$coldata["repairBypassValve"] = $filesop[197];
$coldata["repairInletValve"] = $filesop[198];
$coldata["repairOutletValve"] = $filesop[199];
$coldata["latitude"] = $filesop[200];
$coldata["longitude"] = $filesop[201];
$coldata["onsiteSurveyTestCost"] = $filesop[202];
$coldata["onsiteSurveyTestRepairCost"] = $filesop[203];
$coldata["offsiteSurveyTestCost"] = $filesop[204];
$coldata["offsiteSurveyTestRepairCost"] = $filesop[205];
$coldata["onsiteTestOnlyCost"] = $filesop[206];
$coldata["onsiteTestRepairOnlyCost"] = $filesop[207];
$coldata["onsiteRepairOnly"] = $filesop[208];
$coldata["testPort2"] = $filesop[209];
$coldata["repairCompleteMeterReplacement"] = $filesop[210];
$coldata["repairCompleteMeterReplacementLaborCost"] = $filesop[211];
$coldata["umeCost"] = $filesop[212];
$coldata["umeLaborCost"] = $filesop[213];
$coldata["rotatingLowSideDiskChamber"] = $filesop[214];
$coldata["rotatingLowSideDiskChamberLaborCost"] = $filesop[215];
$coldata["turbineChamberCost"] = $filesop[216];
$coldata["turbineChamberLaborCost"] = $filesop[217];
$coldata["automaticValveCost"] = $filesop[218];
$coldata["automaticValveLaborCost"] = $filesop[219];
$coldata["strainerCost"] = $filesop[220];
$coldata["strainerLaborCost"] = $filesop[221];
$coldata["lowRegisterCost"] = $filesop[222];
$coldata["lowRegisterLaborCost"] = $filesop[223];
$coldata["highRegisterCost"] = $filesop[224];
$coldata["highRegisterLaborCost"] = $filesop[225];
$coldata["miuCost"] = $filesop[226];
$coldata["miuLaborCost"] = $filesop[227];
$coldata["totalCost"] = $filesop[228];
I've read some texts and searched topics, but nothing help me. I'm beginner in PHP. I have array where are variables $qA01_1 up to $qA30_5 and their values can be different 0 or 1 or 5. From array I would like to find all variables with value 1 and make sum. Same for number 5.
$qA01_1 = $_SESSION['qA01_1'];
$qA01_2 = $_SESSION['qA01_2'];
$qA01_3 = $_SESSION['qA01_3'];
$qA01_4 = $_SESSION['qA01_4'];
$qA01_5 = $_SESSION['qA01_5'];
$qA02_1 = $_SESSION['qA02_1'];
$qA02_2 = $_SESSION['qA02_2'];
$qA02_3 = $_SESSION['qA02_3'];
$qA02_4 = $_SESSION['qA02_4'];
$qA02_5 = $_SESSION['qA02_5'];
$qA03_1 = $_SESSION['qA03_1'];
$qA03_2 = $_SESSION['qA03_2'];
$qA03_3 = $_SESSION['qA03_3'];
$qA03_4 = $_SESSION['qA03_4'];
$qA03_5 = $_SESSION['qA03_5'];
$qA04_1 = $_SESSION['qA04_1'];
$qA04_2 = $_SESSION['qA04_2'];
$qA04_3 = $_SESSION['qA04_3'];
$qA04_4 = $_SESSION['qA04_4'];
$qA04_5 = $_SESSION['qA04_5'];
$qA05_1 = $_SESSION['qA05_1'];
$qA05_2 = $_SESSION['qA05_2'];
$qA05_3 = $_SESSION['qA05_3'];
$qA05_4 = $_SESSION['qA05_4'];
$qA05_5 = $_SESSION['qA05_5'];
$qA06_1 = $_SESSION['qA06_1'];
$qA06_2 = $_SESSION['qA06_2'];
$qA06_3 = $_SESSION['qA06_3'];
$qA06_4 = $_SESSION['qA06_4'];
$qA06_5 = $_SESSION['qA06_5'];
$qA07_1 = $_SESSION['qA07_1'];
$qA07_2 = $_SESSION['qA07_2'];
$qA07_3 = $_SESSION['qA07_3'];
$qA07_4 = $_SESSION['qA07_4'];
$qA07_5 = $_SESSION['qA07_5'];
$qA08_1 = $_SESSION['qA08_1'];
$qA08_2 = $_SESSION['qA08_2'];
$qA08_3 = $_SESSION['qA08_3'];
$qA08_4 = $_SESSION['qA08_4'];
$qA08_5 = $_SESSION['qA08_5'];
$qA09_1 = $_SESSION['qA09_1'];
$qA09_2 = $_SESSION['qA09_2'];
$qA09_3 = $_SESSION['qA09_3'];
$qA09_4 = $_SESSION['qA09_4'];
$qA09_5 = $_SESSION['qA09_5'];
$qA10_1 = $_SESSION['qA10_1'];
$qA10_2 = $_SESSION['qA10_2'];
$qA10_3 = $_SESSION['qA10_3'];
$qA10_4 = $_SESSION['qA10_4'];
$qA10_5 = $_SESSION['qA10_5'];
$qA11_1 = $_SESSION['qA11_1'];
$qA11_2 = $_SESSION['qA11_2'];
$qA11_3 = $_SESSION['qA11_3'];
$qA11_4 = $_SESSION['qA11_4'];
$qA11_5 = $_SESSION['qA11_5'];
$qA12_1 = $_SESSION['qA12_1'];
$qA12_2 = $_SESSION['qA12_2'];
$qA12_3 = $_SESSION['qA12_3'];
$qA12_4 = $_SESSION['qA12_4'];
$qA12_5 = $_SESSION['qA12_5'];
$qA13_1 = $_SESSION['qA13_1'];
$qA13_2 = $_SESSION['qA13_2'];
$qA13_3 = $_SESSION['qA13_3'];
$qA13_4 = $_SESSION['qA13_4'];
$qA13_5 = $_SESSION['qA13_5'];
$qA14_1 = $_SESSION['qA14_1'];
$qA14_2 = $_SESSION['qA14_2'];
$qA14_3 = $_SESSION['qA14_3'];
$qA14_4 = $_SESSION['qA14_4'];
$qA14_5 = $_SESSION['qA14_5'];
$qA15_1 = $_SESSION['qA15_1'];
$qA15_2 = $_SESSION['qA15_2'];
$qA15_3 = $_SESSION['qA15_3'];
$qA15_4 = $_SESSION['qA15_4'];
$qA15_5 = $_SESSION['qA15_5'];
$qA16_1 = $_SESSION['qA16_1'];
$qA16_2 = $_SESSION['qA16_2'];
$qA16_3 = $_SESSION['qA16_3'];
$qA16_4 = $_SESSION['qA16_4'];
$qA16_5 = $_SESSION['qA16_5'];
$qA17_1 = $_SESSION['qA17_1'];
$qA17_2 = $_SESSION['qA17_2'];
$qA17_3 = $_SESSION['qA17_3'];
$qA17_4 = $_SESSION['qA17_4'];
$qA17_5 = $_SESSION['qA17_5'];
$qA18_1 = $_SESSION['qA18_1'];
$qA18_2 = $_SESSION['qA18_2'];
$qA18_3 = $_SESSION['qA18_3'];
$qA18_4 = $_SESSION['qA18_4'];
$qA18_5 = $_SESSION['qA18_5'];
$qA19_1 = $_SESSION['qA19_1'];
$qA19_2 = $_SESSION['qA19_2'];
$qA19_3 = $_SESSION['qA19_3'];
$qA19_4 = $_SESSION['qA19_4'];
$qA19_5 = $_SESSION['qA19_5'];
$qA20_1 = $_SESSION['qA20_1'];
$qA20_2 = $_SESSION['qA20_2'];
$qA20_3 = $_SESSION['qA20_3'];
$qA20_4 = $_SESSION['qA20_4'];
$qA20_5 = $_SESSION['qA20_5'];
$qA21_1 = $_SESSION['qA21_1'];
$qA21_2 = $_SESSION['qA21_2'];
$qA21_3 = $_SESSION['qA21_3'];
$qA21_4 = $_SESSION['qA21_4'];
$qA21_5 = $_SESSION['qA21_5'];
$qA22_1 = $_SESSION['qA22_1'];
$qA22_2 = $_SESSION['qA22_2'];
$qA22_3 = $_SESSION['qA22_3'];
$qA22_4 = $_SESSION['qA22_4'];
$qA22_5 = $_SESSION['qA22_5'];
$qA23_1 = $_SESSION['qA23_1'];
$qA23_2 = $_SESSION['qA23_2'];
$qA23_3 = $_SESSION['qA23_3'];
$qA23_4 = $_SESSION['qA23_4'];
$qA23_5 = $_SESSION['qA23_5'];
$qA24_1 = $_SESSION['qA24_1'];
$qA24_2 = $_SESSION['qA24_2'];
$qA24_3 = $_SESSION['qA24_3'];
$qA24_4 = $_SESSION['qA24_4'];
$qA24_5 = $_SESSION['qA24_5'];
$qA25_1 = $_SESSION['qA25_1'];
$qA25_2 = $_SESSION['qA25_2'];
$qA25_3 = $_SESSION['qA25_3'];
$qA25_4 = $_SESSION['qA25_4'];
$qA25_5 = $_SESSION['qA25_5'];
$qA26_1 = $_SESSION['qA26_1'];
$qA26_2 = $_SESSION['qA26_2'];
$qA26_3 = $_SESSION['qA26_3'];
$qA26_4 = $_SESSION['qA26_4'];
$qA26_5 = $_SESSION['qA26_5'];
$qA27_1 = $_SESSION['qA27_1'];
$qA27_2 = $_SESSION['qA27_2'];
$qA27_3 = $_SESSION['qA27_3'];
$qA27_4 = $_SESSION['qA27_4'];
$qA27_5 = $_SESSION['qA27_5'];
$qA28_1 = $_SESSION['qA28_1'];
$qA28_2 = $_SESSION['qA28_2'];
$qA28_3 = $_SESSION['qA28_3'];
$qA28_4 = $_SESSION['qA28_4'];
$qA28_5 = $_SESSION['qA28_5'];
$qA29_1 = $_SESSION['qA29_1'];
$qA29_2 = $_SESSION['qA29_2'];
$qA29_3 = $_SESSION['qA29_3'];
$qA29_4 = $_SESSION['qA29_4'];
$qA29_5 = $_SESSION['qA29_5'];
$qA30_1 = $_POST['qA30_1'];
$qA30_2 = $_POST['qA30_2'];
$qA30_1 = (isset($_POST['qA30_1'])) ? $_POST['qA30_1'] : 0;
$qA30_2 = (isset($_POST['qA30_2'])) ? $_POST['qA30_2'] : 0;
$qA30_3 = (isset($_POST['qA30_3'])) ? $_POST['qA30_3'] : 0;
$qA30_4 = (isset($_POST['qA30_4'])) ? $_POST['qA30_4'] : 0;
$qA30_5 = (isset($_POST['qA30_5'])) ? $_POST['qA30_5'] : 0;
Here is my proposal which do not work. I thing that I should to do something with "array" .
// Sum of all numbers 1
$sumOne = 0;
for ($i = 0; $i <= 3; $i++) {
for($j = 0; $j <= 9; $j++) {
for($k = 1; $k <= 5; $k++){
$u = 'qA_' . $i . $j. '_' . $k;
if ($u==1){
$sumOnet+=1;
}
}
}
}
echo "<br/>SumOne:" . " " . round($sumOne[0], 0);
You really should stick with an array. If you define an array within the $_SESSION array and use that it will be much simpler:
$_SESSION['data']['qA01_1'] = 0;
$_SESSION['data']['qA01_2'] = 1;
$_SESSION['data']['qA01_3'] = 5;
$counts = array_count_values($_SESSION['data']);
if(isset($counts[0])) { echo $counts[0]; } // sum of any 0s is 0 so here is the count
if(isset($counts[1])) { echo $counts[1]; } // sum of any 1s will be the count
if(isset($counts[5])) { echo $counts[5] * 5; }
If I understand the question correctly, you want to sum up all individual values in your array.
You can use array_count_values() for that, it returns you the number of occurances of each value where the value itself is the key:
foreach (array_count_values($_SESSION) as $value => $count) {
echo 'sum of ' . $value . ' values: ' . ($value * $count) . "<br>";
}
No idea where the POST variables fit in though...
<?php
$row = 0;
$handle = fopen("data20150804.log", "r");
while (!feof($handle) ) {
$line_of_text = fgetcsv($handle, 1024, ",");
$num = count($line_of_text);
$timeStamp = $line_of_text[0];
$visibility = $line_of_text[1];
$pressure = $line_of_text[2];
$rain = $line_of_text[3];
$temperature = $line_of_text[4];
$humidity = $line_of_text[5];
$dewpoint = $line_of_text[6];
$R1windSpeed = $line_of_text[7];
$R1wSpeed3s = $line_of_text[8];
$R1wSpeed2min = $line_of_text[9];
$R1wSpeed10min = $line_of_text[10];
$R1windDirDeg = $line_of_text[11];
$R1wDirDeg3s = $line_of_text[12];
$R1wDirDeg2min = $line_of_text[13];
$R1wDirDeg10min = $line_of_text[14];
$R2windSpeed = $line_of_text[15];
$R2wSpeed3s = $line_of_text[16];
$R2wSpeed2min = $line_of_text[17];
$R2wSpeed10min = $line_of_text[18];
$R2windDirDeg = $line_of_text[19];
$R2wDirDeg3s = $line_of_text[20];
$R2wDirDeg2min = $line_of_text[21];
$R2wDirDeg10min = $line_of_text[22];
$gust = $line_of_text[23];
//$row++;
}
fclose($handle);
?>
my csv file is keeping generate the data in a few second.
I want to remove the last row of the csv because my system is reading the last row data and my last row is blank.
If you check the documentation for fgetcsv you'll see the note about blank line returns. So if you do a check after:
$line_of_text = fgetcsv($handle, 1024, ",");
Along the lines of:
if (count($line_of_text) == 0 || $line_of_text[0] === null) {
continue;
}
This should do what you need.
Try this one
<?php
$row = 0;
$file = new SplFileObject("data20150804.log.csv");
$file->setFlags(SplFileObject::READ_CSV);
$file->setFlags(SplFileObject::SKIP_EMPTY);
foreach ($file as $line_of_text) {
$num = count($line_of_text);
$timeStamp = $line_of_text[0];
$visibility = $line_of_text[1];
$pressure = $line_of_text[2];
$rain = $line_of_text[3];
$temperature = $line_of_text[4];
$humidity = $line_of_text[5];
$dewpoint = $line_of_text[6];
$R1windSpeed = $line_of_text[7];
$R1wSpeed3s = $line_of_text[8];
$R1wSpeed2min = $line_of_text[9];
$R1wSpeed10min = $line_of_text[10];
$R1windDirDeg = $line_of_text[11];
$R1wDirDeg3s = $line_of_text[12];
$R1wDirDeg2min = $line_of_text[13];
$R1wDirDeg10min = $line_of_text[14];
$R2windSpeed = $line_of_text[15];
$R2wSpeed3s = $line_of_text[16];
$R2wSpeed2min = $line_of_text[17];
$R2wSpeed10min = $line_of_text[18];
$R2windDirDeg = $line_of_text[19];
$R2wDirDeg3s = $line_of_text[20];
$R2wDirDeg2min = $line_of_text[21];
$R2wDirDeg10min = $line_of_text[22];
$gust = $line_of_text[23];
}
?>
I hope it will help full for you.
I write a prestashop module which allows adding new products. I have a problem: in table 'ps_products' it saves all the information with success but when I open added product in admin panel catalog-> products, the quantity is 0 and no supplier is selected. Here is my code:
$message = '';
$erori = false;
$arr = array();
$feats = array();
$imgs = array();
$arr['nume_produs'] = Tools::getValue('pr_name');
$arr['pr_pret_ach'] = Tools::getValue('pr_pret_ach');
$arr['pr_pret_angro'] = Tools::getValue('pr_pret_angro');
$arr['pr_supp'] = explode("=", Tools::getValue('pr_supp'));
$arr['pr_refer'] = Tools::getValue('pr_refer');
$arr['pr_manuf'] = Tools::getValue('pr_manuf');
$arr['pr_short_desc'] = Tools::getValue('pr_short_desc');
$arr['proxy'] = Tools::getValue('proxy');
$res = yamarketsync::update_proxy($arr['proxy']);
$arr['categorii'] = Tools::getValue('categoryBox');
if(Tools::getValue('active') == 1) $arr['activ'] = true;
else $arr['activ'] = false;
$product = new Product();
$langId = (int) (Configuration::get('PS_LANG_DEFAULT'));
$name_ro = Tools::getValue('pr_name_ro');
if(Tools::getValue('pr_name_ru') != '')$name_ru = Tools::getValue('pr_name_ru'); else $name_ru = $name_ro;
if(Tools::getValue('pr_name_en') != '')$name_en = Tools::getValue('pr_name_en'); else $name_en = $name_ro;
if(Tools::getValue('pr_name_uk') != '')$name_uk = Tools::getValue('pr_name_uk'); else $name_uk = $name_ro;
$s_desc_ro = Tools::getValue('pr_short_desc_ro');
if(Tools::getValue('pr_short_desc_ru') != '')$s_desc_ru = Tools::getValue('pr_short_desc_ru'); else $s_desc_ru = $s_desc_ro;
if(Tools::getValue('pr_short_desc_en') != '')$s_desc_en = Tools::getValue('pr_short_desc_en'); else $s_desc_en = $s_desc_ro;
if(Tools::getValue('pr_short_desc_uk') != '')$s_desc_uk = Tools::getValue('pr_short_desc_uk'); else $s_desc_uk = $s_desc_ro;
$desc_ro = Tools::getValue('pr_desc_ro');
if(Tools::getValue('pr_desc_ru') != '')$desc_ru = Tools::getValue('pr_desc_ru'); else $desc_ru = $desc_ro;
if(Tools::getValue('pr_desc_en') != '')$desc_en = Tools::getValue('pr_desc_en'); else $desc_en = $desc_ro;
if(Tools::getValue('pr_desc_uk') != '')$desc_uk = Tools::getValue('pr_desc_uk'); else $desc_uk = $desc_ro;
$product->id_supplier = $arr['pr_supp'][0];
$product->supplier_name = $arr['pr_supp'][1];
$product->id_manufacturer = Tools::getValue('pr_manuf');
$product->description_short = array('4' => $s_desc_ro, '3' => $s_desc_ru, '1' => $s_desc_en,'5' => $s_desc_uk);
$product->description = array('4' => $desc_ro, '3' => $desc_ru, '1' => $desc_en,'5' => $desc_uk);
$product->quantity = Tools::getValue('pr_cant');
$product->name = array('4' => $name_ro, '3' => $name_ru, '1' => $name_en,'5' => $name_uk);
$product->price = Tools::getValue('pr_pret_ach');
$product->wholesale_price = Tools::getValue('pr_pret_angro');
$product->active = $arr['activ'];
$product->id_category_default= $arr['categorii'][0];
$product->category=$arr['categorii'];
$product->reference = $arr['pr_refer'];
$product->link_rewrite = array('4' => Tools::link_rewrite($name_ro),'3' => Tools::link_rewrite($name_ru),'1' => Tools::link_rewrite($name_en),'5' => Tools::link_rewrite($name_uk));
$res = $product->add();
if(!$res) $erori = true;
//adaugam features
$num = Tools::getValue('feat_num');
$i=0;
$id_product = (int)$product->id;
while($i <= $num){
if( Tools::getValue('feat_name-'.$i) !='' && Tools::getValue('feat_value-'.$i) != ''){
if(!yamarketsync::exista_deja_asociere(Tools::getValue('ya_feature_name-'.$i), Tools::getValue('feat_name-'.$i) )){
yamarketsync::save_asociere(Tools::getValue('ya_feature_name-'.$i), Tools::getValue('feat_name-'.$i) );
}
$rezultat = Product::addFeatureProductImport($id_product, Tools::getValue('feat_name-'.$i), Tools::getValue('feat_value-'.$i));
if(!$rezultat) $erori = true;
}
$feats[$i]['name'] = Tools::getValue('feat_name-'.$i);
$feats[$i]['value'] = Tools::getValue('feat_value-'.$i);
$i++;
}
$i=0;
$num = Tools::getValue('img_num');
while($i < $num){
$imgs[$i] = Tools::getValue('image-'.$i);
$img = new Image();
$img->id_product = $product->id;
$img->add();
$rezultat = AdminImportController::copyImg2($product->id, $img->id, $imgs[$i]);
if(!$rezultat) $erori = true;
$i++;
}
if($erori == true) return $this->displayError($this->l('Au aparut erori in timpul salvarii.'));
else return $this->displayConfirmation($this->l('Modificarile au fost salvate.'));
My friend, add this to complete update product quantity:
StockAvailable::setQuantity((int)$product->id, 0, $product->quantity, $this->context->shop->id)
I have problem that my sms messages are imported with csv, then it is checked if number is ok and how long sms is. My problem is that if text messages is longer then 160 it still enters 1 in databse. But it should start counting, if it is less or equal than 160, it is 1 messages, if it is more than 160 but less or equal than 320 it is two messages and if it is more then it is 3 messages.
Page code is here:
<?php
$link = #mysql_connect("localhost", "admin", "") or die("Error: Database offline.");
mysql_select_db("database", $link);
mysql_query("SET NAMES 'utf8' ", $link);
function detect_type($smstext) {
$type = 0;
$dec_codes = array();
for ($i = 0; $i < strlen($smstext); $i++) {
$symbol = substr($smstext,$i,1);
if (!in_array(ord($symbol), $dec_codes)) { $type = 1; }
}
return $type;
}
$result_array = array();
$unic_numbers = array();
$fp = file_get_contents($_FILES['filename']['tmp_name']);
$fp = str_replace("\r\n", "\n", $fp);
$fp = str_replace("\r", "\n", $fp);
$fp = str_replace("\t", "", $fp);
$rows = explode("\n", $fp);
$imported_rows = 0;
$duplicate_rows = 0;
$error_rows = 0;
$long_rows = 0;
for ($i = 0; $i < sizeof($rows); $i++) {
$data = explode(";", $rows[$i]);
$data[1] = sms_formatNumbers($data[1]); // formating number
$userid = 78;
if(strlen($data[1]) > 9){
if($unic_numbers[$data[1]] != true ){ // unic number check
$unic_numbers[$data[1]] = true;
$imported_rows++;
$fullSMS = iconv("ISO-8859-1","UTF-8", trim($data[2])." ".trim($data[3])." ".trim($data[4]));
if(strlen($fullSMS) > 164){
$long_rows++;
}
if($_POST['action'] == 'send'){
// SMS TEXT
$smstext = str_replace("õ", "ò", $fullSMS);
$smstext = str_replace("Õ", "ò", $smstext);
$type = detect_type($smstext);
// servicegroup
$char2 = substr($data[1], 0, 2);
$char3 = substr($data[1], 0, 3);
$c1 = mysql_query("SELECT * FROM zone_info WHERE country_code = '".$char2."'", $link);
$c2 = mysql_query("SELECT * FROM zone_info WHERE country_code = '".$char3."'", $link);
if (mysql_num_rows($c1) == 1) {
$r = mysql_fetch_array($c1);
$price = $r['price'];
$z = mysql_query("SELECT * FROM zone WHERE id = ".$r['up']."", $link);
$zone = mysql_fetch_array($z);
$zone_id = $zone['id'];
$servicegroup = $zone['servicegroup'];
} else if (mysql_num_rows($c2) == 1) {
$r = mysql_fetch_array($c2);
$price = $r['price'];
$z = mysql_query("SELECT * FROM zone WHERE id = ".$r['up']."", $link);
$zone = mysql_fetch_array($z);
$zone_id = $zone['id'];
$servicegroup = $zone['servicegroup'];
}
require_once("../scripts/number.class.php");
$receiver = "00".$data[1];
$obj = new NumberClass($receiver);
$operator = $obj -> operator_code;
$country = $obj -> code;
$operator_name = $obj -> operator_name;
if(strlen($operator) > 0) {
$er = mysql_query("SELECT * FROM zone_exception WHERE country = ".$country." AND operator = ".$operator."", $link);
if (mysql_num_rows($er) == 1) {
$erand = mysql_fetch_array($er);
$price = $erand['price'];
$servicegroup = $erand['servicegroup'];
}
} else $operator_name = "-";
if ($operator_name == "-") { $servicegroup = $servicegroup; }
else {
if ($operator_name == " First Operator") $servicegroup = "90";
else if ($operator_name == "Second Operator") $servicegroup = "91";
else if ($operator_name == "Third Operator") $servicegroup = "92";
else $servicegroup = $servicegroup;
}
require_once("../core/init.mini.inc.php");
$servicegroup = UserBasedRerouting($receiver, $userid, $operator_name, $servicegroup);
$client_type ='corporative';
$sender = $data[0];
$zone_id = 11;
$client_sms_id = '0';
$client_want_report = '0';
$client_report_url = '';
$amount = 1;
$dt_delaysend = '1970-01-01 00:00:00';
$SMSsent = 0;
$SMStotal = 1;
$smstext_old = $smstext;
while($SMSsent < $SMStotal){
$sql = mysql_query("insert into sms_queue (user_id,client_type,dt_entered,sender,receiver,operator,smstext,sms_type,zone_id,client_sms_id,client_want_report,client_report_url,sms_price,amount,servicegroup,dt_delaysend) values ('$userid','$client_type','".date('Y-m-d H:i:s')."','$sender','$receiver','$operator_name','$smstext',0,'$zone_id','$client_sms_id','$client_want_report','$client_report_url','$price','$amount','$servicegroup','$dt_delaysend')", $link);
$SMSsent++;
}
}
}else{
$duplicate_rows ++;
}
}else{
$error_rows++;
}
}
$result_array['success'] = true;
$result_array['long_sms'] = $long_rows;
$result_array['send_sms'] = $imported_rows;
$result_array['error_sms'] = $error_rows;
$result_array['duplicate_sms'] = $duplicate_rows;
$result_array['action'] = $_POST['action'];
echo json_encode($result_array);
function sms_formatNumbers($number){
$number = (int)$number;
$start_code = (int)substr($number,0,4);
if($start_code < 3780 or $start_code == 3785 or $start_code > 3789){
return $number;
}else{
return '';
}
}
?>
Can someone help me out with that?
Thank you
Try
if(strlen($fullSMS) > 164){
$long_rows = ceil(strlen($fullSMS)/160);
}
instead of
if(strlen($fullSMS) > 164){
$long_rows++;
}