-
Posts
24,572 -
Joined
-
Last visited
-
Days Won
823
Everything posted by Barand
-
The manual explains it.
-
One POS software for many customers, design database
Barand replied to nitiphone2021's topic in Application Design
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 | +-----------------+ -
Good thinking, Batman! $vars = array_reverse(str_split(base_convert($input, 16, 2)));
-
Ah yes. The "bury your head in the sand" method. If you can't see them, the errors don't exist.
-
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; }
-
Can anyone help me find the problem in my php code form?
Barand replied to rocknrolla's topic in PHP Coding Help
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. -
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;
-
You could treat that .env file as an ini file. For example... $envs = parse_ini_file('myproject.env'); echo $envs['API_KEY']; //-> secret key
-
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 )
-
Show multiple pages of PDFs in the same PDF file.
Barand replied to sashavalentina's topic in PHP Coding Help
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 -
... as this is an English-speaking site.
-
Try specifying the image path from your site's root, not the file system root. ie "/news/img/posts/"
-
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"; }
-
You have already posted this question. Closing.
-
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.
-
Have you checked the value in $image_ext?
-
Make sure you have defined the function insert(). It's not a PHP function. (Or did you mean isset() ?)
-
If you are uploading a file you should be using the $_FILES array, not $_POST for the image.
-
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
-
Calling an API and Testing within PHP (noobie help needed)
Barand replied to GalenAltaiir's topic in PHP Coding Help
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 } -
Calling an API and Testing within PHP (noobie help needed)
Barand replied to GalenAltaiir's topic in PHP Coding Help
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. -
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;
-
Everything you need is here... https://www.php.net/manual/en/ https://dev.mysql.com/doc/refman/5.7/en/introduction.html
-
Looks like you've found the answer by yourself