Jump to content

micky007

Members
  • Posts

    33
  • Joined

  • Last visited

Profile Information

  • Gender
    Male
  • Location
    Standish, Lancashire, UK
  • Age
    28

micky007's Achievements

Member

Member (2/5)

0

Reputation

  1. Ah ok I understand now. Thank you very much!
  2. Thank you very much @Barand. Worked exactly as i wanted. I do have another one I'm not struggling with which is this, I'm trying to get the ConsignmentNo. I have tried each of the below without success. echo $arr->OrderAddresses->ConsignmentNo; echo $arr->OrderAddresses[0]->ConsignmentNo; echo $arr[0]['ConsignmentNo']; echo $arr[1]['ConsignmentNo']; Here is the Array. Array ( [OrderLines] => Array ( [0] => Array ( [Description] => Product Name [Brand] => ABCD [Quantity] => 1 [SellingPrice] => 3.68 [BudgetCode] => [LedgerCode] => [OnHold] => [PartNum] => FG5675446345 ) ) [OrderAddresses] => Array ( [0] => Array ( [BOOrderNum] => 6547467 [AccountName] => Name 1 [AccountNumber] => [FirstName] => Fname [LastName] => Lname [Address1] => My Address [Address2] => 2nd PArt [City] => MANCHESTER [County] => [PostCode] => AB1 2CD [Country] => UK [ConsignmentNo] => 547645363546 [NumberOfContainers] => 1 [PackageType] => Box [Carrier] => FEDEX ) ) [OrderNumber] => M123456 [Placed] => 2022-08-17T14:04:47.653 [TotalPrice] => 3.68 [ConsignmentNo] => [DeliveryType] => Standard [Weight] => 0.45 ) Thank you again for your support.
  3. Hi, I've been reading a lot of tutorials from other sites on how to get a value from a JSON array but none of them seem to work for me. I have the below JSON I'm trying to get the value of OrderNumber and place it within its own variable. But all the tutorials I've read don't have the [ at the beginning of their JSON. So everything I'm trying doesn't seem to be working for me. [{"OrgID":"1234567890987654321","OrderNumber":"M123456","OrigOrderNumber":"","Placed":"2022-08-17T14:04:47.653","PostCode":"AB1 2CD","BackOfficeOrderNumber":"12345678","CustomerName":"My Name","OutletName":"My Name Two","OrderStatus":"Delivered","OrderRef":"O-0012345678","AddressCount":1}] Any help would be much appreciated please. Thank you.
  4. Hi, I have a string with the value of { "success": true, "delivered": true, "contactDetailsRequired": false, "message": "Signed For by: D ANDERSON ", "signature": "https://webservices.thedx.co.uk/PodImage/ImageHandler.ashx?tn=906732192165", "date": "21-07-2020", "serviceLevelName": "Consigned", "time": "13:33:19", "trackedProductName": "DataExchange" } How do i go about placing the values into variables so for example: $success = "true"; $delivered = "true"; $message = "Signed for by: D ANDERSON"; etc.... My mind has gone blank and im having one of those days, any help would be greatly appreciated. Thanks
  5. Hey CPD, I'm still new to PHP and not an expert at it, so this JOINs thing is new to me & not sure what it is. I've just updated the server to the newest PHP and added MySQLi. I've now changed my code for it to work with MySQLi but now nothing is working. All its doing now is just echoing "ISP Checks completed!". <?php require("./databaseconnection.php"); //Get Database Login Information //Do ISP Check $mysqli = new mysqli(localhost,$username,$password, $database); $result = mysqli_query($link, "SELECT * FROM `leads` WHERE `IPCheck` = 'NO'"); $numberrows=mysqli_num_rows($result); echo $numberrows; while($row = mysqli_fetch_array($result)) { $ipcountry=$row['IPCountry']; $ipcc=$row['IPCC']; $ipisp=$row['IPISP']; $leadid=$row['LeadID']; $ProgramID=$row['ProgramID']; //Get Valid Consumer ISP $result2 = mysqli_query($link2, "SELECT * FROM `ValidISP` WHERE `ISP` = '$ipisp'"); echo $link2."<br/>"; $count=mysqli_num_rows($result2); echo $count."<br/>"; var_dump($result2); echo "<br />"; if($count==1){ while($row2 = mysqli_fetch_array($result2)) { $validisp=$row2['ISP']; $validispstatus=$row2['Status']; } }else { $validispstatus="MANUALCHECK"; } //End if ( $validispstatus == "PASS" ) { mysqli_query($link3, "UPDATE leads SET IPCheck='PASS' WHERE LeadID='$leadid'"); } elseif ( $validispstatus == "FAIL" ) { mysqli_query($link4, "UPDATE leads SET IPCheck='FAIL' WHERE LeadID='$leadid'"); } else { mysqli_query($link5, "UPDATE leads SET IPCheck='MANUAL' WHERE LeadID='$leadid'"); } } mysqli_close(); //End echo "ISP Checks completed!"; ?> I'm really stuck as i dont know whats wrong. What im trying to do is "SELECT * FROM `leads` WHERE `IPCheck` = 'NO'". I need it then to grab the value of the column called IPISP and also the column called LeadID of each record that matches the Query. While it grabs the data of each record i then need it do perform the following: "SELECT * FROM `ValidISP` WHERE `ISP` = '$ipisp'" - $ipisp is the data it has just got from a record from the column IPISP. I need it then to count how many rows come up from that query. If theres 1 row (there should really only be 1 or 0 rows) then i need it to grab the data from the above query from the column Status If theres 0 rows then i need $validispstatus set as MANUAL I then need the below code to be ran, im sure you can work out what im trying to do from the code: if ( $validispstatus == "PASS" ) { mysqli_query($link3, "UPDATE leads SET IPCheck='PASS' WHERE LeadID='$leadid'"); } elseif ( $validispstatus == "FAIL" ) { mysqli_query($link4, "UPDATE leads SET IPCheck='FAIL' WHERE LeadID='$leadid'"); } else { mysqli_query($link5, "UPDATE leads SET IPCheck='MANUAL' WHERE LeadID='$leadid'"); } Do you understand fully what im trying to do here? Help would be much appreciated please. Thank you!
  6. Hi Guys, My count is echoing the $count variable as 0 when it should be 1. When i run the MySQL Query myself in PHPMYADMIN it returns a row. So why when i echo $count is it showing as 0? Any help would be great. Thanks in advance! <?php require("./databaseconnection.php"); //Get Database Login Information //Do ISP Check mysql_connect(localhost,$username,$password) or die(mysql_error()); @mysql_select_db($database) or die( "Oops theres an error, our highly trained monkeys have been notified."); $query = "SELECT * FROM `leads` WHERE `IPCheck` = 'NO'"; $result=mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)) { $ipcountry=$row['IPCountry']; $ipcc=$row['IPCC']; $ipisp=$row['IPISP']; $leadid=$row['LeadID']; $ProgramID=$row['ProgramID']; //Get Valid Consumer ISP $query2 = "SELECT * FROM `ValidISP` WHERE `ISP` = '$ipisp'"; $result2=mysql_query($query2); echo $query2."<br/>"; $count=mysql_num_rows($result2); echo $count."<br/>"; var_dump($result2); echo "<br />"; if($count==1){ while($row2 = mysql_fetch_array($result2)) { $validisp=$row2['ISP']; $validispstatus=$row2['Status']; } }else { $validispstatus="MANUALCHECK"; } //End if ( $validispstatus == "PASS" ) { $query3 = "UPDATE leads SET IPCheck='PASS' WHERE LeadID='$leadid'"; mysql_query($query3); } elseif ( $validispstatus == "FAIL" ) { $query3 = "UPDATE leads SET IPCheck='FAIL' WHERE LeadID='$leadid'"; mysql_query($query3); } else { $query3 = "UPDATE leads SET IPCheck='MANUAL' WHERE LeadID='$leadid'"; mysql_query($query3); } } mysql_close(); //End echo "ISP Checks completed!"; ?> As you can see if used var_dump($result2); and thats echoing this out "resource(4) of type (mysql result)" I've no idea why its showing that as when i run the Query in PHPMYADMIN it displays a row of data. See the images below. Example: WHEN I TRY IT IN PHPMYADMIN IT RETURNS A ROW: Any help would be great please.
  7. What im trying to do is get how many characters there are in the variable called postcode. If theres 6 characters then it will echo the code. If theres 7 characters then it will echo different code. The script also removes any spaces in the data that the variable holds. Thanks.
  8. Hi Guys, I've managed to code what i need it do to but i have an issue, below is my code: $postcode=$_GET['postcode']; function countchar ($string) { $resultpostcode = strlen ($string) - substr_count($string, ' '); echo $resultpostcode; } countchar ($postcode); if ( $resultpostcode == 6 ) { echo "Postcode1 "; echo substr($postcode, 0, 3); echo "<br>"; echo "Postcode2 "; echo substr($postcode, 3); } elseif( $resultpostcode == 7 ){ echo "Postcode1 "; echo substr($postcode, 0, 4); echo "<br>"; echo "Postcode2 "; echo substr($postcode, 4); }else { echo "error"; } If the value of postcoderesult is 6 (it even outputs 6) then it wont echo what it should be doing, the same if its 7. It just keeps echoing Error. Any help would be great please. Thank you.
×
×
  • 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.