Jump to content

Barand

Moderators
  • Posts

    24,572
  • Joined

  • Last visited

  • Days Won

    823

Everything posted by Barand

  1. The manual explains it.
  2. Yes Unique customer id identifies the customer in the data Add new record to customer table Example +---------------+ | customer | +---------------+ | customer_id |-------+ +-----------------+ +----------------+ | customer_name | | | basket | | product | | email | | +-----------------+ +----------------+ | mobile | | | basket_id |-------+ +-----------------+ +-------| product_id | | etc | | | basket_date | | | basket_item | | | description | +---------------+ +------<| customer_id | | +-----------------+ | | price | +-----------------+ | | item_id | | +----------------+ +------<| basket_id | | | product_id |>-----+ | quantity | +-----------------+
  3. Good thinking, Batman! $vars = array_reverse(str_split(base_convert($input, 16, 2)));
  4. Ah yes. The "bury your head in the sand" method. If you can't see them, the errors don't exist.
  5. Well done. For the record... $input = 'B1'; // hex iput $decimal = base_convert($input, 16, 10); // convert to 177 for ($k=0; $k<8; $k++) { $vars[$k] = ($decimal & 2**$k) ? 1:0; }
  6. My mother taught me always to practise safe text and never accept links from strangers. Post the relevant code (using the <> button in the toolbar.) And tell us exactly what error message you are getting.
  7. These all have the same value +------------+------------+------------+ | Binary | Decimal | Hex | +------------+------------+------------+ | 10110001 | 177 | B1 | +------------+------------+------------+ In my code, setting $binary3 to any of these will give the same result $binary3 = 0b10110001; $binary3 = 177; $binary3 = 0xB1;
  8. You could treat that .env file as an ini file. For example... $envs = parse_ini_file('myproject.env'); echo $envs['API_KEY']; //-> secret key
  9. Still forgetting unpack(), for 8 bits to 8 vars $binary3 = 0b10110001; for ($k=0; $k<8; $k++) { $vars[$k] = ($binary3 & 2**$k) ? 1:0; } giving $vars = Array ( [0] => 1 [1] => 0 [2] => 0 [3] => 0 [4] => 1 [5] => 1 [6] => 0 [7] => 1 )
  10. Your program structure should look like this require 'tcpdf.php' database connection define class MYPDF handle POST request single query to get all required data initialize pdf doc foreach order_id add new page outout invoice for order_id end foreach output pdf doc
  11. ... as this is an English-speaking site.
  12. Try specifying the image path from your site's root, not the file system root. ie "/news/img/posts/"
  13. Your first one is missing a } before the else. Syntax is if (condition) { do something } else { do something else } It looks like $em is not valid. Have you tried var_dump($em) to check what's in there? PS You could just... if ( ($em = filter_var($em, FILTER_VALIDATE_EMAIL)) === false ) { echo "Invalid format"; }
  14. You have already posted this question. Closing.
  15. This is the method I use, storing the data in an array indexed by parentId No need to store the "level". It works that out itself. Store the "left-margin" values for each level in the css.
  16. Have you checked the value in $image_ext?
  17. Make sure you have defined the function insert(). It's not a PHP function. (Or did you mean isset() ?)
  18. If you are uploading a file you should be using the $_FILES array, not $_POST for the image.
  19. I see two syntax errors if (insert($_POST['register_button'])) { The { has no corresponding } later in the code. if (filter_var($em, FILTER_VALIDATE_EMAIL)) { $em = filter_var($em, FILTER_VALIDATE_EMAIL) ^ } missing ; at the end of the line
  20. A couple of points about your processing: 1 ) As your first heading is "lmk_key" and the second is "address1", it appears that the data actually starts halfway through element 89, and that somewhere along the way whatever split the headings from the data has become a space character 2 ) Exploding on "," isn't working as the address data itself contains a comma, thus splitting that data over two elements ... [89] => low-energy-fixed-light-count 1229391483952014103108154495749528 [90] => "142 [91] => Edgar Road" Better to use str_getcsv() which knows how to process ... , "142, Edgar Road", ... If I change that space in the middle of element 89 to a |, then $str = 'lmk-key,address1,address2,address3,postcode,building-reference-number,current-energy-rating,potential-energy-rating,current-energy-efficiency,potential-energy-efficiency,property-type,built-form,inspection-date,local-authority,constituency,county,lodgement-date,transaction-type,environment-impact-current,environment-impact-potential,energy-consumption-current,energy-consumption-potential,co2-emissions-current,co2-emiss-curr-per-floor-area,co2-emissions-potential,lighting-cost-current,lighting-cost-potential,heating-cost-current,heating-cost-potential,hot-water-cost-current,hot-water-cost-potential,total-floor-area,energy-tariff,mains-gas-flag,floor-level,flat-top-storey,flat-storey-count,main-heating-controls,multi-glaze-proportion,glazed-type,glazed-area,extension-count,number-habitable-rooms,number-heated-rooms,low-energy-lighting,number-open-fireplaces,hotwater-description,hot-water-energy-eff,hot-water-env-eff,floor-description,floor-energy-eff,floor-env-eff,windows-description,windows-energy-eff,windows-env-eff,walls-description,walls-energy-eff,walls-env-eff,secondheat-description,sheating-energy-eff,sheating-env-eff,roof-description,roof-energy-eff,roof-env-eff,mainheat-description,mainheat-energy-eff,mainheat-env-eff,mainheatcont-description,mainheatc-energy-eff,mainheatc-env-eff,lighting-description,lighting-energy-eff,lighting-env-eff,main-fuel,wind-turbine-count,heat-loss-corridor,unheated-corridor-length,floor-height,photo-supply,solar-water-heating-flag,mechanical-ventilation,address,local-authority-label,constituency-label,posttown,construction-age-band,lodgement-datetime,tenure,fixed-lighting-outlets-count,low-energy-fixed-light-count|1229391483952014103108154495749528,"142, Edgar Road",,,TW4 5QP,5844359278,D,C,61,73,Maisonette,End-Terrace,2014-10-30,E09000027,E14001005,Greater London Authority,2014-10-31,marketed sale,57,73,241,152,4,46,2.5,56,56,747,473,155,125,87,Single,Y,3rd,Y,,2104,100,double glazing installed during or after 2002,Normal,0,5,5,100,0,From main system,Good,Good,"Solid, no insulation (assumed)",N/A,N/A,Fully double glazed,Good,Good,"Cavity wall, as built, no insulation (assumed)",Poor,Poor,None,N/A,N/A,"Flat, limited insulation (assumed)",Very Poor,Very Poor,"Boiler and radiators, mains gas",Good,Good,Programmer and room thermostat,Average,Average,Low energy lighting in all fixed outlets,Very Good,Very Good,mains gas (not community),1,unheated corridor,5,,0,,natural,"142, Edgar Road",Richmond upon Thames,Twickenham,HOUNSLOW,England and Wales: 1967-1975,2014-10-31 08:15:44,owner-occupied,11,11'; $arr = []; foreach (explode('|', $str) as $line) { $arr[] = str_getcsv($line); } echo '<pre>' . print_r(array_combine($arr[0], $arr[1]), 1) . '</pre>'; outputting... Array ( [lmk-key] => 1229391483952014103108154495749528 [address1] => 142, Edgar Road [address2] => [address3] => [postcode] => TW4 5QP [building-reference-number] => 5844359278 [current-energy-rating] => D [potential-energy-rating] => C [current-energy-efficiency] => 61 [potential-energy-efficiency] => 73 [property-type] => Maisonette [built-form] => End-Terrace [inspection-date] => 2014-10-30 [local-authority] => E09000027 [constituency] => E14001005 [county] => Greater London Authority [lodgement-date] => 2014-10-31 . . . etc }
  21. I get the impression that there should be 2 arrays in that data. The first 90 or so elements look like headings and the final 90 look like data. Could be there is something like a "\n" in the middle that isn't showing. You may need 2 explodes. The first to split the results into records and the second to split those records into fields.
  22. The string you posted appears to be missing its enclosing { .. }. With those it becomes a correctly formatted JSON string... $details = '{"customer_details":{"email":"[email protected]","tax_exempt":"none","tax_ids":[]}}'; you can then decode the string... $data = json_decode($details); then access the email address with... $email = $data->customer_details->email;
  23. Everything you need is here... https://www.php.net/manual/en/ https://dev.mysql.com/doc/refman/5.7/en/introduction.html
  24. Looks like you've found the answer by yourself
  25. You can't embed php code in the middle of a string like that. You could do... $htmlcontent .=" <tr> <td>".$year."</td> <td align=\"center\"> "; if(count($singlecount[$year])>0) { $htmlcontent .= (count($singlecount[$year])); } else { $htmlcontent .= "-"; } $htmlcontent .= "</td>"; // etc
×
×
  • 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.