-
Posts
24,361 -
Joined
-
Last visited
-
Days Won
798
Posts posted by Barand
-
-
3 minutes ago, Table said:
Anny suggestions would be appreciated.
Look at the example in the manual (the one you already read) and change the syntax of your code to match the correct version.
-
24 minutes ago, ginerjm said:
$row = mysqli_fetch_assoc()($query_result);
Have you read any documentation???? The above statement is so wrong. Read the manual.
Requinix already told them that - item #4 in his "other errors" list.
-
"table" is a mysql reserved word and therefore a poor choice of name. If you must used a reserved word as an identifier for a table or column then you have to enclose it in backticks...
SELECT COUNT(row1) AS aantal FROM `table` WHERE ...
-
What are theactual date values in your database that you expect be found by the WHERE clause?
-
What a waste of effort.
Try
$servername = "mysql.woodjoint.com"; $username = "MyUsername"; $password = "MyPassword"; $db = "woodjoint"; mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); $conn = mysqli_connect($servername, $username, $password, $db); $sql = 'SELECT title , venue , address FROM shows'; $result = $conn->query($sql); foreach ($result as $row) { echo "Title :{$row['Title']} <br> ". "Venue : {$row['Venue']} <br> ". "Address : {$row['Address']} <br> ". "--------------------------------<br>"; }
Specify the fields you need in the SELECT, not "*".
You specified the default db when you connected so no need to select the db again.
With a mysqli result object (but not with a statement object if you used a prepared query) you can simply use foreach() to loop through the results.
My advice is to switch to PDO for future projects.
-
Call mysqli_report just before you call mysqli_connect
mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); $conn = mysqli_connect($servername, $username, $password,$db); . . .
Ensure php error_reporting is on and tht error_display is also on.
-
Moved to PHP forum
-
7 minutes ago, Realest89 said:
does this forum have like a discord
See big green button at top of the page.
-
Q.E.D.
Youe need to ensure you only attempt to update the database when $_SESSION['user_id'] has a value.
Somethng like this at the start of your script ...
if (!isset($_SESSION['user_id'])) { header("Location: login.php"); exit; }
-
What does this output? ...
var_dump($_SESSION['user_id']);
-
Looks like $_SESSION['user_id'] is NULL. Have you checked its value?
-
1 hour ago, ginerjm said:
Maybe to a course in how to write English
I doubt he's aspiring to reach standard achieved in your earlier post in this thread
-
try
foreach($dom2->find("li span a") as $el) { echo $el->getAttribute('href') . '<br>'; // https://playpass.com/robinson-girls-youth-softball-association }
-
Do you mean something like the last 7 lines of the initial post?
-
11 minutes ago, wilsoc31 said:
can you not use preg_match_all to read a file.txt and parse it out?
I suppose , if you insist on using a hammer to drive in a screw. Not the right tool for the job.
-
Send a location header to same page so it reload without the posted data
myscript.php:
if ($_SERVER['REQUEST_METHOD']=='POST') { // validate POST data if (no errors) { // update database header("Location: myscript.php"); exit; } } // build page content
-
FetchAll() returns an array but in the second version you don't store it anywhere.
- 1
-
perhaps
select i.name as itemName, qs.name as sectionName, i.id as itemId, i.GBP, i.USD, i.CAD, cb.charge_by, COUNT(cp.item_id) > 0 as icConsumable from items i inner join quote_sections qs on i.section_id=qs.id inner join charge_by cb on i.charge_by_id = cb.id left join consumable_price cp ON i.id = cp.item_id group by i.id union select ci.name as itemName, qs.name as sectionName, concat("CI", ci.id) as itemId, ci.price as GBP, ci.price as USD, ci.price as CAD, cb.charge_by, 0 as isConsumable from custom_item ci inner join quote_sections qs on ci.section_id=qs.id inner join charge_by cb on ci.charge_by = cb.id
-
That will work if slow queries are your thing
-
Do you want to show
- all items with indication that it is in consumables, or
- only items where there is a consumables record, or
- only items with no consumables records
(I have to ask as you have not given an example where you used the table)
-
LEFT JOIN ( SELECT item_id, COUNT(*) as tot FROM consumables GROUP BY item_id ) con USING (item_id)
If you use a subquery like the above, instead of joining directly to the table, it will eliminate the duplicate rows.
-
Give us some context - that tells us nothing.
What is the name of that table and what is the query giving the problem?
EDIT: Note - you need a join on item_id AND qty BETWEEN min AND max
-
2 minutes ago, webdeveloper123 said:
$reservedrooms = $_POST['reservedrooms'] ?? '';
That is setting $resrved rooms to a string value if not posted. The default needs to be an empty array
$reservedrooms = $_POST['reservedrooms'] ?? [];
-
Shouldn't give that error then. It should just give a zero price because none of the booked query room ids are that empty array.
Are you sure it's not being overwritten anywhere?
Import data from excel to databse
in PHP Coding Help
Posted
According to the error message, the relevant file is cell.php. You seem to have posted everything but that.