thefollower Posted October 14, 2008 Share Posted October 14, 2008 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 More sharing options...
discomatt Posted October 14, 2008 Share Posted October 14, 2008 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' ) ); ?> Link to comment https://forums.phpfreaks.com/topic/128381-solved-log-query-errors/#findComment-665130 Share on other sites More sharing options...
thefollower Posted October 14, 2008 Author Share Posted October 14, 2008 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 Link to comment https://forums.phpfreaks.com/topic/128381-solved-log-query-errors/#findComment-665156 Share on other sites More sharing options...
discomatt Posted October 14, 2008 Share Posted October 14, 2008 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. Link to comment https://forums.phpfreaks.com/topic/128381-solved-log-query-errors/#findComment-665171 Share on other sites More sharing options...
thefollower Posted October 14, 2008 Author Share Posted October 14, 2008 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 Link to comment https://forums.phpfreaks.com/topic/128381-solved-log-query-errors/#findComment-665179 Share on other sites More sharing options...
ionik Posted October 14, 2008 Share Posted October 14, 2008 this would be much easier if you setup a MySQL Wrapper Class.... example query Function : mysql_query($this->sql) or $this->logError(); and your logError funciton would simply be mysql_query('INsert ERROR'); die('Message'); Link to comment https://forums.phpfreaks.com/topic/128381-solved-log-query-errors/#findComment-665187 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.