Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Q]Php code

Newbie Spellweaver
Joined
Nov 6, 2007
Messages
87
Reaction score
0
what's wrong with this code? :/
here it is:
PHP:
<?php
$MSSQL_connect = mssql_connect('localhost', 'sa', '');
mssql_select_db("kal_db",$MSSQL_connect);
$query = "INSERT INTO Item (PID ,IID ,Index,Prefix, Info, Num, MaxEnd, CurEnd, SetGem, XAttack, XMagic, XDefense, XHit, XDodge, Protect, UpgrLevel, UpgrRate)
VALUES ('517','2343','1','0','0','". $_POST['num'] ."','4','4','0','0','0','0','0','0','0','0','0')";
$res = mssql_query($query);
if ($res)
{
      echo "The item was bought successfully!";
}
else
      echo "Something is wrong, the item couldn't be bought";
?>
<html>
<body>
<form method="post" name="frm" id="frm" action="">
Amount of The Specified Item :<br><input type="text" id="num" name="num" maxlength="4" />
<input type="submit" value="Buy" />
</form>
</body>
</html>
and that's the error report:
Code:
Warning: mssql_query() [function.mssql-query]: message: Incorrect syntax near the keyword 'Index'. (severity 15) in C:\xampp\htdocs\siteshoptest.php on line 6

Warning: mssql_query() [function.mssql-query]: Query failed in C:\xampp\htdocs\siteshoptest.php on line 6
 
Live Now, Work Later
Joined
Sep 12, 2006
Messages
153
Reaction score
4
(PID ,IID ,Index,Prefix, Info, Num, MaxEnd, CurEnd,

look at the spaces between words and commas.

in short:

keyword 'Index'.
Query failed

the query failed cos of something wrong near the keyword 'Index'.
 
Upvote 0
Newbie Spellweaver
Joined
Nov 6, 2007
Messages
87
Reaction score
0
i have tried a lot of things even changing the word Index but it still makes me that error near the word i changed
 
Upvote 0
Experienced Elementalist
Joined
Dec 27, 2006
Messages
288
Reaction score
4
It's blatantly obvious. Near the keyword Index. It's telling you that Index is a keyword, and its incorrect to have it where it is.

Solution: Change Index to [Index].
 
Upvote 0
Newbie Spellweaver
Joined
Nov 6, 2007
Messages
87
Reaction score
0
ok i will try (hope it works) and i will edit this post after.

Edit: zomg it worked :))) man you are the best!!!
 
Upvote 0
Back
Top