Derikoe Derikoe - 1 year ago 72
PHP Question

Can't seem to get query to work?



include ('connect.php');

$budgetboxvar = $_POST['budgetbox'];

$sql="INSERT INTO users WHERE username = '".$_SESSION['usernamebox']."'(budget) VALUES ('$budgetboxvar')";



Does anyone have an idea why the code above doesn't work ? It seems like the code works if I leave the code below out. I'm sorry but I can't seem to figure out how this is not correct ? I'm not getting any error messages either.

When I take out the
WHEN username is SESSION usernamebox
part out.. the query does input into my database, only not in the field of a logged in user..

I tried to echo something if the query succeeded but it doesn't show anything either.. Which means the query can't be executed (I think). Can't figure out why though(it's hard being a noob sometimes)

Thank you in advance, hope you can help !

Answer Source

$query = $db->prepare("UPDATE users SET budget=? WHERE username=?"); ///statements voorbereiden

$budgetboxvar = $_POST['budgetbox'];
$name = $_SESSION['usernamebox']; //var toekennen

$query->bind_param("ss", $budgetboxvar, $name);
echo"Thank you for entering your budget!";  

And.. i changed the database column "budget" to VARCHAR64

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download