Jump to content

[SOLVED] You have an error in your SQL syntax; check the manual that corresponds?


vexious

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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