-
Posts
24,566 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
Finishing a school assignment about a shopping cart
Barand replied to Niksou's topic in PHP Coding Help
All you should be sending to the cart is product id and quantity. Never allow the user the specify their own price, otherwise you'll end up selling everything for 0.01. On the cart page, query the database to get price and description. -
Is it objecting to the missing "$return" parameter? try $CI->db =& DB($params, false, $active_record);
-
A couple of caveats for the record... 1 ) 2020-01-01, without the quotes, evaluates to 2018 (2020 minus 1 minus 1) but I'm sure it was just a typo in this instance. 2 ) if dateinfo is a datetime type then you need to make sure you use only its date portion when comparing against '2020-07-19' (which is actually '2020-07-19 00:00:00'). If datainfo were to contain '2020-07-19 01:00:00' then it would be outside the range if you don't compare DATE(dateinfo)
-
Ho do they get or save a list of datain the same column in database?
Barand replied to mahenda's topic in PHP Coding Help
-
Set the values in the php.ini file instead of using ini_set() all the time. That's what it's for. If you have a startup error the code won't even execute, so not of those ini_set()s can happen. Therefore ini_set('dispay_startup_errors', 1) is as much use as a chocolate teapot.
-
The user doesn't input the value on checkboxes or radio buttons <button>s are just another type of html element which allow the programmer to set a value independent of its label. In the example below, the value of the clicked button would be sent in $_POST['gender'] <button name='gender' value='M'>Male</button> <button name='gender' value='F'>Female</button>
-
Your $_POST values do not match what is posted. Try a very simple piece of code from "Debugging 101" echo '<pre>' . print_r($_POST, 1) . '</pre>'; so you can see what is being posted
-
Where to start? If those fields (page_url, link_anchor_text etc) all exist in the form then after the form is posted all those POSTed values will be set. In particular, $_POST['page_url'] will be set so no others will be checked. If $_POST['page_url'] is empty then your SESSION variable will be empty. It needs to contain a valid column name, hence your sql error. You need to be setting the SESSION value to column name, not the content of the form field.
-
Which of those 34 lines is line 97?
-
By referencing the file system path to the file or by defining an included files folder in your php.ini file.
-
Yeah, must be tough. I was only in my 50s when I started learning PHP.
-
Post the code that's giving the problem. We are not clairvoyant.
-
You have a couple of options 1 ) Re-format the date in the SQL query when you retrieve the records. EG SELECT DATE_FORMAT(invoice_date_created, '%d.%m.%Y') as invoice_date_created 2 ) Re-format after retrieval in the array $transaction['invoice_date_created'] = date('d.m.Y', strtotime($transaction['invoice_date_created']));
-
PHP function to convert Hex to HSL (Not HSL to Hex)
Barand replied to thara's topic in PHP Coding Help
Not quite. var_dump($delta) gives float(0), therefore the first branch needs to be either if ($delta === 0.0) { or if ($delta == 0) { -
PHP function to convert Hex to HSL (Not HSL to Hex)
Barand replied to thara's topic in PHP Coding Help
$templatePrimaryColor = '555555'; echo '<pre>',print_r(hexToHsl($templatePrimaryColor)).'</pre>'; -> Warning: Division by zero in C:\inetpub\wwwroot\test\winuser\noname3.php on line 14 -
PHP function to convert Hex to HSL (Not HSL to Hex)
Barand replied to thara's topic in PHP Coding Help
Yes, if all 3 components are equal then $delta is zero, giving a division by zero error. -
PHP function to convert Hex to HSL (Not HSL to Hex)
Barand replied to thara's topic in PHP Coding Help
Your method has a fatal problem with greys (ie when R = G = B) -
A php function - retrieval ban for present and future?
Barand replied to samanj's topic in PHP Coding Help
Restrict your db query with a where clause so you only retrieve the records you want SELECT ... WHERE datecol BETWEEN input_date AND CURDATE() - INTERVAL 1 DAY -
Change your query to retrieve the extra item and restructure the $data array to store it. $data = []; $res = $conn->prepare("SELECT name , email -- extra item , month(month) as mno , paid FROM fee WHERE month >= ? ORDER BY name, month "); $res->execute([$start]); foreach ($res as $row) { if (!isset($data[$row['name']])) { $data[$row['name']] = [ 'email' => $row['email'], 'pays' => $empty_array ]; } $data[$row['name']]['pays'][$row['mno']] = $row['paid']; }
-
Was This A Php Issue Or An Html5 Drop Down Issue ?
Barand replied to 2020's topic in PHP Coding Help
It's neither a PHP thing nor a HTML5 thing - it's a plain, old HTML <select> thing. By default, if none of the options have their selected attribute set, the first option is shown as selected. -
So the user doesn't have to guess which radio button is for "Male" and which is for "Female" of course.
-
No. \ is the escape character so needs to be \\ in a dir path. The final \ also needs to be \\ as it is currently escaping the quote at the end of the string. Easier is to use / in paths (even on windows)
-
When you use <label for="xxx"> then the xxx should be the id of the object being labelled. This is useful with radio buttons or checkboxes and enables the user to click either the object or the label to check or uncheck. In your examples, <label for="yes"> is wrong since "yes" is not an id of anything.
-
When you get a keyboard that adds indenting and line breaks I'll read your code.
-
I prefer option 4. EG mysqli_report(MYSQLI_REPORT_ALL|MYSQLI_REPORT_STRICT); $conn = mysqli_connect('localhost', 'someuser', 'wrong_password', 'test');