Program Parkir Dengan Php
I want to retrieve data from MySql table. I am using Xampp, phpMyAdmin etc.. I followed this tutorial step by step: https://www.youtube.com/watch?v=IHdd02IK2Jg
But I get this error:
Notice: Undefined variable: records in C:XAMPPhtdocsdisplay_prsc.php on line 29
And a warning: Darussalam books in urdu free download pdf.
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, null given in C:XAMPPhtdocsdisplay_prsc.php on line 29
It just displays the column names when i run it.
5 Answers
Note the space in your first php tag. You have <? php
, it should be <?php
And since it seems you are starting to learn, avoid learning things deprecated. Don't use MySQL, use PDO or Mysqli.
You have a few errors in your code:
1. Wrong php opening tag
You have to remove the space in your php opening tag, e.g.
2. Weird html
Almost your entire html is wrong! I would recommend you to read a book or watch a basic html tutorial
So your entire code should look something like this:
Solidworks 2017 torrent crack. N64 controller serial protocol sniffer. Side Notes:
1. What can be improved?
- I would do some basic error checking e.g. if the connection failed and so on
- Use
mysqli_*
with prepared statements, orPDO
with prepared statements, they are much safer! (We live in 2015) - (Also if the guy in your tutorial uses
mysql_*
, change the tutorial!)
So that you don't only have your old code working, here your improved code:
2. Coding side notes
Add error reporting to the top of your file(s) which will help find errors.
Error reporting should only be done in staging, and never production.
I recommend you using Prepared statements for MySQL instead of clean MySQL, it's not secure at all, and will give you problems later on.
A lille guide here.
http://www.w3schools.com/pHp/php_mysql_prepared_statements.asp
There are multiple errors in your code. But for the error, it is due to mysql_query()
returns FALSE at line:
Then, the line while ($new=mysql_fetch_assoc($records)){
cannot get the value of $records
, thus produce the errors.
Other errors are:
HTML
- missing DOCTYPE
- missing meta charset
- a missing
</tr>
- a misplaced
</head>
- be modern, use CSS to style your HTML instead of using HTML tag attributes
PHP
- didn't check the return value of functions before using them
- use of deprecated
mysql_*
functions; use PDO / MySQLi instead - extra space at
<? php