Jump to content

[SOLVED] log query errors?


thefollower

Recommended Posts

I was wondering if it is possible do queries with an idea of insert the query errors to a table so the "or die (mysql_error()); would infact be like:

 

<?php
mysql_query =  ("select * from table")
  Or die(
mysql_query("insert into errorlog (log)
   values (mysql_error())");
);
?>

 

I have some thing like that which is:

 

<?php
$INSERT  = mysql_query("INSERT INTO logs (`custom`,`eventtime`)
	VALUES ('$custom','$date')")
	Or die( $var = mysql_error();
$insert = mysql_query("INSERT INTO gamelogs (Log,LogTime)
			VALUES('$var'$Date')");
);
?>

 

But every method i try i get syntax issues i also tried:

<?php
$insert = mysql_query("INSERT INTO gamelogs (Log,LogTime)
			VALUES('mysql_error()'$Date')")
?>

 

But that just inserted the string "mysql_error()" lol ... hope you can help me out..

Link to comment
https://forums.phpfreaks.com/topic/128381-solved-log-query-errors/
Share on other sites

Your first example is ideal... with the exception of a few minor syntax errors

<?php

mysql_query =  ("select * from table")
Or die(
	mysql_query( "INSERT INTO `errorlog` ( `log` ) VALUES ('".mysql_error()."')" )
);

?>

 

I would even go as far as this

 

<?php

mysql_query("select * from table")
Or die(
	mysql_query( "INSERT INTO `errorlog` ( `log` ) VALUES ('".mysql_error()."')" )
		Or die( 'Error writing to error logs' )
);

?>

Ok tried that but doesn't seem to work as it acts like the line is still going... here is what i am on about:

 

 

<?php
$INSERT  = mysql_query("INSERT INTO logs (`custom`,`eventtime`)
	VALUES ('$custom','$Date')")
	Or die( mysql_query( "INSERT INTO `gamelogs` ( `Log`,`LogTime` ) VALUES ('".mysql_error()."','$Date')" ));

If(mysql_affected_rows()>0){

// code

}
?>

 

I get this error:

PHP Parse error:  syntax error, unexpected T_IF on line 32

 

 

Hope you can help me out

I'm not sure... but these lines

 

$INSERT  = mysql_query("INSERT INTO logs (`custom`,`eventtime`)
      VALUES ('$custom','$Date')")
      Or die( mysql_query( "INSERT INTO `gamelogs` ( `Log`,`LogTime` ) VALUES ('".mysql_error()."','$Date')" ));

 

execute without error on my server. This leads me to believe you have a syntax issue elsewhere.

I'm not sure... but these lines

 

$INSERT  = mysql_query("INSERT INTO logs (`custom`,`eventtime`)
      VALUES ('$custom','$Date')")
      Or die( mysql_query( "INSERT INTO `gamelogs` ( `Log`,`LogTime` ) VALUES ('".mysql_error()."','$Date')" ));

 

execute without error on my server. This leads me to believe you have a syntax issue elsewhere.

 

Yes you are correct i did!

 

Thank you

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.