No error showing using mysql_error() function. msqli_query() is working fine but when i add mysql_error beside it, i receive nothing in web page even thou the query is invalid and connection is wrong.
example. mysqli_query($link, $query) or die(mysql_error()); <--- Nothing comes up
link script:
<?php
#SET DATABASE CREDENTIALS
$mysql_host = 'localhost';
$mysql_username = 'root';
$mysql_password = 'root';
$mysql_db = 'attendance';
$mysql_error = 'Error: connection';
//TEST CONNECTION
$link = mysqli_connect( $mysql_host, $mysql_username, $mysql_password, $mysql_db) or die($mysql_error);
if(mysqli_connect_errno())
{
printf("Connection Failed: %s\n", mysqli_connect_error());
exit();
}
?>
Query Script:
<?php
require('conn.php'); <--- **No Problem**
$query = "SELsECT * FROM `$TBL` WHERE `textFromDate` >= '".mysql_real_escape_string($date1)."' AND `textToDate` <= '".mysql_real_escape_string($date2)."' AND `Scheme`='Paid'";
$resultwholeday = mysqli_query($link, $wholeday) or die(mysql_error()); <--- **might have problem**
?>
Use mysqli_error()
: http://php.net/manual/en/mysqli.error.php
As far as I know (I may be wrong), every mysql_* function has a relative mysqli_* function. They do not work as substitutes.
EDIT (addressing comment):
According to PHP.net's mysqli_error()
docs, it requires one argument to be passed:
string mysqli_error ( mysqli $link )
This mysqli $link that you are passing will be the variable that contains your database connection information. So you create a mysqli connection and save it to $link. Then run some queries. mysqli_error($link)
will find the last error that has occurred on $link (or the mysqli connection).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With