I just got another problem with SQL and this time, mysql_error() isn't throwing anything... in fact... nothing is giving me any information as to why it's not working.
Well... the only error I see is the one I have my db class write into my own log
[Fri Apr, 01 7:22:15 PM] Error setting MySQL Resource. SQL used: "INSERT INTO `cms_track` (`trackID`, `userID`, `user-agent`, `pageFrom`, `pageTo`, `timeVisited`, `userIP`) VALUES ('0', '0', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16', 'null', 'C:/wamp/www/CMS/index.php', '1301685735', '127.0.0.1')"
But as to why, mysql_error() isn't throwing anything and I don't know. It had 2000+ entries in it so I know it worked and then I thought it was possible that there were just too many entries, so I truncated the table, but it still gives me the same error.
Another weird thing, that even though it's giving me the error, the SQL is still carried out which leads me to believe the error comes from my SQL function rather then the SQL itself.
Below is the function that I use:
<?php
public function resource($sql = null, $return = false)
{
// Checking if we are connected to MySQL
if(!is_resource($this->mysql_link))
{
$this->connect();
}
// Checking if the SQL is empty
if(is_null($sql))
{
$sql = $this->get_last_sql();
}
// Getting the resource into a variable
$resource = mysql_query($sql);
// Setting the last result variable
$this->last_result = $resource;
// Checking if the resource was created properly
if(is_resource($resource))
{
// Checking if we are returning the result
if($return)
{
return $resource;
}
// Otherwise we are returning true
return true;
}
else
{
// Logging the error if need be
if($this->log_errors === true)
{
$this->log_error('Error setting MySQL Resource. SQL used: "' . $sql . '"');
}
// Checking if we need to kill the script
if($this->silent == false)
{
die(mysql_error());
}
// It was a failure... return false
return false;
}
}
?>
- <?php
- public function resource($sql = null, $return = false)
- {
- // Checking if we are connected to MySQL
- if(!is_resource($this->mysql_link))
- {
- $this->connect();
- }
-
- // Checking if the SQL is empty
- if(is_null($sql))
- {
- $sql = $this->get_last_sql();
- }
-
- // Getting the resource into a variable
- $resource = mysql_query($sql);
-
- // Setting the last result variable
- $this->last_result = $resource;
-
- // Checking if the resource was created properly
- if(is_resource($resource))
- {
- // Checking if we are returning the result
- if($return)
- {
- return $resource;
- }
-
- // Otherwise we are returning true
- return true;
- }
- else
- {
- // Logging the error if need be
- if($this->log_errors === true)
- {
- $this->log_error('Error setting MySQL Resource. SQL used: "' . $sql . '"');
- }
-
- // Checking if we need to kill the script
- if($this->silent == false)
- {
- die(mysql_error());
- }
-
- // It was a failure... return false
- return false;
- }
- }
- ?>
"Bring forth therefore fruits meet for repentance:" Matthew 3:8