-
Posts
24,423 -
Joined
-
Last visited
-
Days Won
806
Posts posted by Barand
-
-
10 minutes ago, Jason92 said:
but something is wrong with the php code thats supposed to display this data
Perhaps you could give us a clue
- What is it doing that it shouldn't do
- What is it not doing that it should do?
-
From the php manual...
QuoteTroubleshooting
The most common problem with installing OCI8 is not having the Oracle environment correctly set. This typically appears as a problem using oci_connect() or oci_pconnect(). The error may be a PHP error such as Call to undefined function oci_connect(), an Oracle error such as ORA-12705, or even an Apache crash. Check the Apache log files for startup errors and see the sections above to resolve this problem.
While network errors like ORA-12154 or ORA-12514 indicate an Oracle network naming or configuration issue, the root cause may be because the PHP environment is incorrectly set up and Oracle libraries are unable to locate the tnsnames.ora configuration file.
-
Then your "MyPHPScript.php" should
- retrieve the inputs from the $_GET array
- Send the email
- Update the database
- Use http_build_query() to rebuild the querystring then use header("Location: NEW URL WITH QUERYSTRING) to send to remote page.
19 minutes ago, InternetGuy said:If I can just see such a script
= euphemism for "if someone will write it for me (for free)", which is probably why you can't get the answer you really want.
-
Seriously!? You let anyone delete any record from any table just by putting values in a query string?
http://.../delete.php?target=user&username=admin
Brownie points for trying to use "prepare()" but your usage is wrong. The $id variable should not be in the query (that's the whole point of prepared statements). Use a placeholder instead and pass the id as a parameter
$stmt = $pdo->prepare("DELETE FROM SOME_DATABASE.$table WHERE $idType = ?"); $status = $stmt->execute( [$id] );
-
Here's an example
if ($_SERVER['REQUEST_METHOD']=='POST') { $post = array_map('trim', $_POST); if (!empty($post['productid']) && !empty($post['qty'])) { if (!isset($_SESSION['cart'][$_POST['productid']])) { $_SESSION['cart'][$_POST['productid']] = 0; } $_SESSION['cart'][$_POST['productid']] += $_POST['qty']; } }
from an earlier topic of yours !
-
Plus I doubt if you'd be interested in the odd cents if you are selling a $5,000,000,000 aircraft carrier.
Although if your prices were in guineas...
-
I assume you've had a go at it yourself by now. Here's my effort...
<?php $data = []; for ($r=0; $r<4; $r++) { for ($c=0; $c<4; $c++) { $data[$r][$c] = rand(0,1); } } $rowcounts = $colcounts = []; for ($r=0; $r<4; $r++) { $rowcounts[$r] = count(array_keys($data[$r], 1)); } for ($c=0; $c<4; $c++) { $colcounts[$c] = count(array_keys(array_column($data,$c), 1)); } $rmax = max($rowcounts); $cmax = max($colcounts); $rcmax = max($rmax, $cmax); $hirows = array_keys($rowcounts, $rcmax); $hicols = array_keys($colcounts, $rcmax); echo "<table border='1' style='border-collapse:collapse'>\n"; for ($r=0; $r<4; $r++) { echo "<tr>"; for ($c=0; $c<4; $c++) { $hilite = (in_array($r, $hirows) || in_array($c, $hicols)) ? 'class="max"' : ''; echo "<td $hilite> {$data[$r][$c]} </td>"; } echo "</tr>\n"; } echo "</table>\n"; ?>
-
1
-
-
Do you have this line in your php.ini file...
;extension=php_oci8_12c.dll
If so, remove the ";" to enable the extension and check you have that dll file in your extensions folder.
-
Sounds like you don't the required library installed or enabled. Check the extensions in the php.ini file or use phpinfo() to see if there is an OCI section.
-
If you are selling warships, why not indeed. Whatever your application requires.
-
1
-
-
Make sure your php.ini file has error_reporting set to "E_ALL" and that display_errors and display_startup_errors are ON
You also need to check for any errors returned by your DB server.
-
I store prices as decimal EG
+-------------+------------------+------+-----+----------------------+--------------------------------+ | Field | Type | Null | Key | Default | Extra | +-------------+------------------+------+-----+----------------------+--------------------------------+ | prod_id | int(11) | NO | PRI | NULL | auto_increment | | description | varchar(50) | YES | | NULL | | | price | decimal(10,2) | YES | | NULL | | +-------------+------------------+------+-----+----------------------+--------------------------------+
Query example...
TABLE: product TABLE: cart +---------+-------------+--------+ +----+---------+------+ | prod_id | description | price | | id | prod_id | qty | +---------+-------------+--------+ +----+---------+------+ | 1 | Product AZ | 49.99 | | 1 | 1 | 2 | | 2 | Product B | 29.99 | | 2 | 3 | 5 | | 3 | Product C | 9.99 | | 3 | 7 | 1 | | 4 | Product D | 22.99 | | 4 | 6 | 2 | | 5 | Product E | 29.99 | +----+---------+------+ | 6 | Product F | 19.99 | | 7 | Product G | 129.99 | | 8 | Product H | 99.99 | | 9 | Product I | 74.99 | | 10 | Product J | 69.99 | +---------+-------------+--------+ SELECT p.prod_id , p.description , p.price , c.qty , p.price * c.qty as total FROM test_product p JOIN test_cart c USING (prod_id); +---------+-------------+--------+------+--------+ | prod_id | description | price | qty | total | +---------+-------------+--------+------+--------+ | 1 | Product AZ | 49.99 | 2 | 99.98 | | 3 | Product C | 9.99 | 5 | 49.95 | | 7 | Product G | 129.99 | 1 | 129.99 | | 6 | Product F | 19.99 | 2 | 39.98 | +---------+-------------+--------+------+--------+
-
@NotSunfighter He was shown exactly how to do it in a previous topic of his in this forum. Not worth wasting any more time.
-
30 minutes ago, makamo66 said:
I'm doing something like that
Doesn't sound like you are doing anything like that.
In my code, if the product isn't in the cart it adds it, with the quantity. If the product is already in the cart it updates the quantity.
No removals required (unless, of course, the user wants to cancel)
-
You cannot send headers when anything has already been output.
You need to reorganize your code so that the php processing precedes the html output.
-
3 minutes ago, makamo66 said:
but I need to delete the product that's the last item in the SESSION array
Why?
-
e.g. A custom UOM of "furlongs per fortnight" makes the top speed of your car sound very impressive.
-
Well, you've output a table of 0s and 1s, but what are you going to count?
Store the random 0/1s in a two-dimensional array then count the array contents.
Output the array into the table.
-
2 hours ago, webchambers1 said:
                                                                                                                  
Really!?
Hard to believe that, with your markup, you are actually using css files.
-
Looks like the prepare() failed.
Put this line before your mysqli connection so that errors are trapped
mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT);
(if you don't have display_errors ON check your error log.)
-
If you want always to go back 2 years, then a slight modification to my above code
<?php // CREATE A RANGE OF MONTHS // $dt1 = new DateTime('-2 years'); $dt2 = new DateTime(); $dp = new DatePeriod($dt1, new DateInterval('P1M'), $dt2); // STARTING FRIDAY // $fri = clone $dt1; $fri->modify('last friday of previous month'); // LOOP THROUGH THE MONTHS // // AND STORE IN months ARRAY // $months = []; foreach ($dp as $d) { $key = $d->format('Y-m'); $months[$key]['start'] = $fri->modify('+1 days')->format('Y-m-d'); // add 1 day to previous friday for start date $fri = $d->modify('last friday of this month'); // get last friday of the month for end date $months[$key]['end'] = $fri->format('Y-m-d'); } // CHECK THE RESULTS // echo '<pre>'; printf("<b>%-14s%s</b>\n", 'Month', 'Fiscal month'); printf("<b>%-10s%10s — %-10s</b>\n", '', 'Saturday', 'Friday'); print("--------+------------------------\n"); foreach ($months as $k => $m) { printf("%-7s | %-10s — %-10s\n", $k, $m['start'], $m['end']); } print("--------+------------------------\n"); echo '</pre>'; ?>
Giving
Month Fiscal month Saturday — Friday --------+------------------------ 2017-11 | 2017-10-28 — 2017-11-24 2017-12 | 2017-11-25 — 2017-12-29 2018-01 | 2017-12-30 — 2018-01-26 2018-02 | 2018-01-27 — 2018-02-23 2018-03 | 2018-02-24 — 2018-03-30 2018-04 | 2018-03-31 — 2018-04-27 2018-05 | 2018-04-28 — 2018-05-25 2018-06 | 2018-05-26 — 2018-06-29 2018-07 | 2018-06-30 — 2018-07-27 2018-08 | 2018-07-28 — 2018-08-31 2018-09 | 2018-09-01 — 2018-09-28 2018-10 | 2018-09-29 — 2018-10-26 2018-11 | 2018-10-27 — 2018-11-30 2018-12 | 2018-12-01 — 2018-12-28 2019-01 | 2018-12-29 — 2019-01-25 2019-02 | 2019-01-26 — 2019-02-22 2019-03 | 2019-02-23 — 2019-03-29 2019-04 | 2019-03-30 — 2019-04-26 2019-05 | 2019-04-27 — 2019-05-31 2019-06 | 2019-06-01 — 2019-06-28 2019-07 | 2019-06-29 — 2019-07-26 2019-08 | 2019-07-27 — 2019-08-30 2019-09 | 2019-08-31 — 2019-09-27 2019-10 | 2019-09-28 — 2019-10-25 --------+------------------------
-
9 hours ago, jakebur01 said:
when outputting to the browser,
Why would it need a default name to output the image in the browser?
Or are you wanting the user to download the image?
-
-
You can generate a date preiod object to loop through a range of months
<?php // CREATE A RANGE OF MONTHS $dt1 = new DateTime('2019-01-01'); $dt2 = new DateTime('2020-01-01'); $months = []; $dp = new DatePeriod($dt1, new DateInterval('P1M'), $dt2); // STARTING FRIDAY $prev_fri = new DateTime('last friday of december 2018'); // LOOP THROUGH THE MONTHS foreach ($dp as $d) { $key = $d->format('Y-m'); $months[$key]['start'] = $prev_fri->modify('+1 days')->format('Y-m-d'); // add 1 day to previous friday for start date $fri = $d->modify('last friday of this month'); // get last friday of the month for end date $months[$key]['end'] = $fri->format('Y-m-d'); $prev_fri = $fri; // store month end } echo '<pre>', print_r($months, 1), '</pre>'; ?>
Giving
Array ( [2019-01] => Array ( [start] => 2018-12-29 [end] => 2019-01-25 ) [2019-02] => Array ( [start] => 2019-01-26 [end] => 2019-02-22 ) [2019-03] => Array ( [start] => 2019-02-23 [end] => 2019-03-29 ) [2019-04] => Array ( [start] => 2019-03-30 [end] => 2019-04-26 ) [2019-05] => Array ( [start] => 2019-04-27 [end] => 2019-05-31 ) [2019-06] => Array ( [start] => 2019-06-01 [end] => 2019-06-28 ) [2019-07] => Array ( [start] => 2019-06-29 [end] => 2019-07-26 ) [2019-08] => Array ( [start] => 2019-07-27 [end] => 2019-08-30 ) [2019-09] => Array ( [start] => 2019-08-31 [end] => 2019-09-27 ) [2019-10] => Array ( [start] => 2019-09-28 [end] => 2019-10-25 ) [2019-11] => Array ( [start] => 2019-10-26 [end] => 2019-11-29 ) [2019-12] => Array ( [start] => 2019-11-30 [end] => 2019-12-27 ) )
Data not displaying
in PHP Coding Help
Posted
Does your
print_r($attData);
on line 8 show the correct data?