-
Posts
24,607 -
Joined
-
Last visited
-
Days Won
831
Everything posted by Barand
-
Yes. The usual reason is that your query failed. Implement error checking. The easiest way is to add this line mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); just before your call mysql_connect() and make sure you have PHP's error reporting and display errors or log errors turned on
-
The first thing to try is change $con = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME); to mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); $con = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME); so errors in your queries get reported
-
If you are still using that monitor that you bought in 1990, stick with websafe colours.
-
His boat club registration form has two sections You Your boat So, in theory, after validating and preparing two insert queries, you can $member_insert->execute($_POST['member']); $boat_insert->execute($_POST['boat']);
-
It will be in $_POST['boat']['policy_number'];
-
Yes. But if the first element, $myarray[0], is an array, print_r() is going to say array. Why would you expect different?
-
My two example are just two ways of passing the result of first function as an argument to the second function
-
function first() { $A = [1,2,3,4,5]; return $A; } function second($arr) { return array_sum($arr); } $myarray = first(); echo second( $myarray ); //-> 15 // or echo second( first() ); //-> 15
-
Damn! Too slow, again.
-
Your definition is conditional. It only gets defined if the "else" path is followed. Define it as an empty string before the if().
-
Why don't you just create a webpage with a background image?
-
You should be using prepared statements. They have the added benefit that you then dont have to worry about data values like "O'Reilly" or "The Bull's Head"
-
53 years designing and developing business systems and applications, 37 years databases and SQL, 21 years PHP https://dev.mysql.com/doc/refman/5.7/en/functions.html
-
STOP making all the columns varchar. dates should be type DATE Numeric fields should be numeric types (int, float, decimal etc) Sorting and comparing will fail with wrong types EG mysql> create temporary table test (numcol int, charcol varchar(10)); Query OK, 0 rows affected (0.92 sec) mysql> insert into test (numcol, charcol) values (1, '1'), (5, '5'), (100, '100'); Query OK, 3 rows affected (0.05 sec) mysql> select * from test order by numcol; +--------+---------+ | numcol | charcol | +--------+---------+ | 1 | 1 | | 5 | 5 | | 100 | 100 | +--------+---------+ mysql> select * from test order by charcol; +--------+---------+ | numcol | charcol | +--------+---------+ | 1 | 1 | | 100 | 100 | | 5 | 5 | +--------+---------+ mysql> SELECT 100 > 5, '100' > '5'; +---------+-------------+ | 100 > 5 | '100' > '5' | +---------+-------------+ | 1 | 0 | 1 = true +---------+-------------+ 3 rows in set (0.00 sec)
-
Why have you turned auto_commit off? When you connect to the server, are you telling mysqli to report errors? EG... mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); // turn on error reporting $db = mysqli_connect(HOST,USERNAME,PASSWORD,$database); $db->set_charset('utf8');
-
Does this make it easier? SELECT a.ledger_code , l.ledger_name , SUM(IF(type='Dr',amount, null)) as Debits , SUM(IF(type='Cr',amount, null)) as Credits FROM acc_tbl a JOIN ledger_tbl l USING (ledger_code) GROUP BY a.ledger_code; +-------------+---------------------+--------+---------+ | ledger_code | ledger_name | Debits | Credits | +-------------+---------------------+--------+---------+ | 18 | Maintenance | 2400 | | | 30 | Annual Subscription | | 300 | | 5 | cash | 300 | 2400 | +-------------+---------------------+--------+---------+
-
I have been looking at your data model - not a pretty sight Foreign keys in a table should match the primary keys of the referenced table. Your primary keys are INT but the foreign keys in the course table are all VARCHAR - they too should be INT. And why is the FK of tblsubject called "courseTitle"? (I couldn't see any relationship between course and subject until I saw the join your query) Date fields should be type DATE (yyyy-mm-dd). (Already changed in my version of tblstudent) Departments belong to a Faculty, so if you know the department you know the faculty. There is no need for "facultyid" in tblcourse or tblstudent. tblsession is only referenced by tblstudent. I would have thought there is a relationship between session (eg 2021/2022) and semester. Other than via the class/level there is, surprisingly, no relationship between student and course which, to me, seems the main relationship in an educational environment. Do your courses only last for a single semester? Are course and course unit part of the same entity or does a course have many units? YOUR CODE I haven't got it to run yet as changes are required. Your form has Level/Semester/Faculty put your post is expected to contain Level/Semester/Department/Faculty. For reasons known only to you, the semesterId is assigned to $sessionId. The form input should be Department instead of Faculty as faculty is redundant if you have the department. The query will change accordingly. As you only want to display data, POST should be GET.
-
It seems mathematics and Year 7 are a poor example if everyone in Year 7 takes mathematics. In Years 10/11/12 where some students take Science, some Arts and some Commercial, how do you then know who takes which subject? (I may know my way around databases but I do not know the relationships between all the entities in your specific scenario.)