vexious Posted December 11, 2007 Share Posted December 11, 2007 Error I'm getting: There was a problem with the Database! You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND `appname` = 'TheIs'' at line 1 There was a problem with the Database! You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''TheIs',0,1197336648)' at line 1 Code: (Only the top part of the code..) <?php include "conf.php"; include "settings.inc"; if ( checkInvites($user,"TheIs",$_POST['ids'],$mysql) == TRUE ) { include "1.php"; } else { include "2.php"; } function checkInvites($uid, $appName, $ids, $mysql) { $conn = mysql_connect($mysql['host'],$mysql['user'],$mysql['pass']); @mysql_select_db($mysql['db']) or die( "Unable to select database"); $time = time(); if ( $ids == NULL ) { $count = 0; } else { $count = count($ids); } $query = "SELECT `count` FROM invites WHERE `user` = $uid AND `appname` = '$appName'"; $result = mysql_query($query,$conn); if ( !( $result ) ) { echo "There was a problem with the Database!<br/>"; echo mysql_error()."<br/>"; } if( ! ( $row = mysql_fetch_row( $result ) ) ) { $query = "INSERT INTO invites VALUES($uid,'$appName',$count,$time);"; $result = mysql_query($query,$conn); if ( !( $result ) ) { echo "There was a problem with the Database!<br/>"; echo mysql_error()."<br/>"; } if ( $count == 20 ) { $equation = FALSE; } else { $equation = TRUE; } } else { if ( $row[0] == 20 ) { $equation = FALSE; } else { $query = "UPDATE invites SET `count` = count + $count WHERE `user` = $uid AND `appname` = '$appName';"; $result = mysql_query($query,$conn); if ( !( $result ) ) { echo "There was a problem with the Database!<br/>"; echo mysql_error()."<br/>"; } if ( $count + $row[0] > 19 ) { $equation = FALSE; } else { $equation = TRUE; } } } $_count = -($count + $row[0] - 20); if ( $_count > 0 ) { echo "<div style='text-align: center; padding: 15px; font-weight: bold; font-size: 10pt;'>xxxx<span style='font-size: 13pt; color: red; font-weight:bold;'>$_count</span> xxxxxxxxx</div>"; } mysql_close($conn); return $equation; } ?> Link to comment https://forums.phpfreaks.com/topic/81106-solved-you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds/ Share on other sites More sharing options...
revraz Posted December 11, 2007 Share Posted December 11, 2007 Kinda hard for us to help when you don't even include the query. Link to comment https://forums.phpfreaks.com/topic/81106-solved-you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds/#findComment-411538 Share on other sites More sharing options...
Barand Posted December 11, 2007 Share Posted December 11, 2007 I agree. It would be a hell of a lot more use if you showed that part of the code that was generating the errors Link to comment https://forums.phpfreaks.com/topic/81106-solved-you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds/#findComment-411544 Share on other sites More sharing options...
vexious Posted December 11, 2007 Author Share Posted December 11, 2007 Sorry posted full code. Link to comment https://forums.phpfreaks.com/topic/81106-solved-you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds/#findComment-411548 Share on other sites More sharing options...
revraz Posted December 11, 2007 Share Posted December 11, 2007 Put single quotes around all your variables in your SQL syntax. Link to comment https://forums.phpfreaks.com/topic/81106-solved-you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds/#findComment-411564 Share on other sites More sharing options...
vexious Posted December 11, 2007 Author Share Posted December 11, 2007 Still same error Link to comment https://forums.phpfreaks.com/topic/81106-solved-you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds/#findComment-411635 Share on other sites More sharing options...
kevincro Posted December 11, 2007 Share Posted December 11, 2007 try this, you can cut and paste this code as I cut and pasted the entire code from your post. <?php include "conf.php"; include "settings.inc"; if ( checkInvites($user,"TheIs",$_POST['ids'],$mysql) == TRUE ) { include "1.php"; } else { include "2.php"; } function checkInvites($uid, $appName, $ids, $mysql) { $conn = mysql_connect($mysql['host'],$mysql['user'],$mysql['pass']); @mysql_select_db($mysql['db']) or die( "Unable to select database"); $time = time(); if ( $ids == NULL ) { $count = 0; } else { $count = count($ids); } $query = "SELECT `count` FROM invites WHERE `user` = '$uid' AND `appname` = '$appName'"; $result = mysql_query($query,$conn); if ( !( $result ) ) { echo "There was a problem with the Database!<br/>"; echo mysql_error()."<br/>"; } if( ! ( $row = mysql_fetch_row( $result ) ) ) { $query = "INSERT INTO invites VALUES('$uid','$appName','$count','$time');"; $result = mysql_query($query,$conn); if ( !( $result ) ) { echo "There was a problem with the Database!<br/>"; echo mysql_error()."<br/>"; } if ( $count == 20 ) { $equation = FALSE; } else { $equation = TRUE; } } else { if ( $row[0] == 20 ) { $equation = FALSE; } else { $query = "UPDATE invites SET `count` = count + $count WHERE `user` = '$uid' AND `appname` = '$appName';"; $result = mysql_query($query,$conn); if ( !( $result ) ) { echo "There was a problem with the Database!<br/>"; echo mysql_error()."<br/>"; } if ( $count + $row[0] > 19 ) { $equation = FALSE; } else { $equation = TRUE; } } } $_count = -($count + $row[0] - 20); if ( $_count > 0 ) { echo "<div style='text-align: center; padding: 15px; font-weight: bold; font-size: 10pt;'>xxxx<span style='font-size: 13pt; color: red; font-weight:bold;'>$_count</span> xxxxxxxxx</div>"; } mysql_close($conn); return $equation; } ?> Link to comment https://forums.phpfreaks.com/topic/81106-solved-you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds/#findComment-411649 Share on other sites More sharing options...
kevincro Posted December 11, 2007 Share Posted December 11, 2007 I missed something in this line, please cut and paste. $query = "INSERT INTO invites VALUES('$uid','$appName','$count','$time')"; Link to comment https://forums.phpfreaks.com/topic/81106-solved-you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds/#findComment-411653 Share on other sites More sharing options...
revraz Posted December 11, 2007 Share Posted December 11, 2007 You probably missed some Still same error Link to comment https://forums.phpfreaks.com/topic/81106-solved-you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds/#findComment-411657 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.