Jump to content

Mysql Problem


whelpton

Recommended Posts

Hello,

 

I am trying to update a mysql database using the following code:

 

<?php
include('connect.php');
$username = trim(addslashes($_POST['username']));
$way = trim(addslashes($_POST['way']));
$ammount = trim(addslashes($_POST['ammount']));

mysql_query("UPDATE Users SET Credit = Credit '$way' '$ammount' WHERE Username = '$username' LIMIT 1") or die(mysql_error());


?>

 

However, when I do it, It gives me the error: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 ''' '' WHERE Username = '' LIMIT 1' at line 1.

 

Can anyone help me out with where Im going wrong please?

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/202322-mysql-problem/
Share on other sites

For more information, this is the form that is being sent to the script.

<form id="form1" name="form1" method="post" action="creditupdate.php">
  :
<label>
    <input name="username" type="text" id="Username" title="username" value="username" />
    </label>
    <label>
    <select name="way">
      <option value="+" selected="selected">+</option>
      <option value="-">-</option>
    </select>
    <input name="ammount" type="text" value="credits" size="10" />
    <input type="submit" name="Submit" value="Update" />
    </label>
</form>

Link to comment
https://forums.phpfreaks.com/topic/202322-mysql-problem/#findComment-1060883
Share on other sites

Edit your query like this

 

mysql_query("UPDATE Users

                      SET Credit = Credit '$way'

                      Something = '$ammount'

                      WHERE Username = '$username'")

or die(mysql_error());

Something is another field. And in the update command, there doesn't have LIMIT condition.

 

Link to comment
https://forums.phpfreaks.com/topic/202322-mysql-problem/#findComment-1060920
Share on other sites

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.