Jump to content

Barand

Moderators
  • Posts

    24,563
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. The minimal number of globals is 0. (And sorry to see your TAB key has broken. :) ) But that aside, If it is form1, $z is not defined. If it isn't form1, $a is not defined. $x is never used. Bit of a mess really.
  2. PS... and have you got "display_startup_errors" set ON.
  3. Are you sure you are checking the php.ini file that is actually being used? phpinfo() which tell you the correct one.
  4. No thanks - no-one will read them. We only want to see what's relevant to the problem.
  5. These are what prompted my remarks Example 1 $stmt = $con->prepare("SELECT participationid, FROM donationclashdetails WHERE usernames, totaldonated = $_SESSION['name'], ?") $stmt->bind_param('isi', $_SESSION['id'], $_SESSION['name'], $_POST['participation']); $stmt->bind_result($participationid, $usernames, $totaldonated,); Query: Syntax errors totaldonated = name (really???) Params binding: 3 parameters but only 1 "?" placeholder (wrongly placed) in the query Result binding: 3 results bound but only 1 column selected Example 2 $stmt = $con->prepare("SELECT userbalance, totaleventjoined, userlevel, userexperience, totaldonationdc, totalpifcoingained FROM accounts WHERE username = $_SESSION['name']") $stmt->bind_param('i', $_SESSION['id']); Query: Syntax error plus WHERE clause is using a name Params binding: parameter is an id (int) with no placeholders in the query
  6. From your code It looks like there are three people working on the script. One writing the queries (who has no regard for query syntax rules), one binding the parameters and a third binding the results - and the three of them never communicate with the other two.
  7. 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
  8. 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
  9. If you are still using that monitor that you bought in 1990, stick with websafe colours.
  10. ORDER BY current_price = 0, current_price A boolean condition returns 0 or 1 (true)
  11. 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']);
  12. It will be in $_POST['boat']['policy_number'];
  13. Yes. But if the first element, $myarray[0], is an array, print_r() is going to say array. Why would you expect different?
  14. My two example are just two ways of passing the result of first function as an argument to the second function
  15. 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
  16. Try it.
  17. Damn! Too slow, again.
  18. Your definition is conditional. It only gets defined if the "else" path is followed. Define it as an empty string before the if().
  19. Why don't you just create a webpage with a background image?
  20. 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"
  21. 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
  22. No No No! Define your DBs default table type as InnoDB and your default charset as UTF8 and stick with those. Don't define tables/columns with different engines and charsets, you are just creating problems for yourself.
  23. 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)
  24. 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');
  25. In that case When posting code, use the code button ( ) When your teacher finds the student/course to add their marks, where are you putting those marks?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.