acer2 Posted June 7, 2008 Share Posted June 7, 2008 Hi,I was wondering if someone knows the answer.I just installed Wamp with: Apache Version : 2.2.8 PHP Version : 5.2.5 andphpMyAdmin - 2.11.5 with MySQL client version: 5.0.45 and Used PHP extensions: mysqli.I want to insert data in a table. The table exist in mysql!I do everything correct but i keep getting this error:Couldn’t execute queryThis is the code:connect.php<?php//connect to database$server='localhost';$host='127.0.0.1';$user='root';$password='';$dbname = 'tester';$cxn = mysqli_connect($host,$user,$password,$dbname)or die ('Couldn’t connect to server.');$username = $_POST["username"];$passwrd = $_POST["passwrd"];$adres = $_POST["adres"];$query = 'INSERT INTO test1 (username, passwrd, adres) VALUES ($username, $passwrd, $adres)';$result = mysqli_query($cxn,$query) or die ('Couldn’t execute query.');echo "Data inserted in table " . ;?></body></htmlThis is the code for the form: add.php<html><head><title> add</title></head><body><form action="adduser.php" method="post"><table width="400" border="0" cellspacing="1" cellpadding="2"><tr><td width="100">User</td><td><input name="username" type="text" id="username"></td></tr><tr><td width="100">Password</td><td><input name="passwrd" type="text" id="passwrd"></td></tr><tr><td width="100">adres</td><td><input name="adres" type="text" id="adres"></td></tr><tr><td width="100"> </td><td> </td></tr><tr><td width="100"> </td><td><input name="add" type="submit" id="add" value="Add New User"></td></tr></table></form></body></html>Hope to get help! Thanks Acer Link to comment Share on other sites More sharing options...
acer2 Posted June 7, 2008 Author Share Posted June 7, 2008 Well, I'm embarred to say that I had made a little mistake .The first variable was numeric, so the quotes ("username") where wrong. And the rest should have been : "$passwrd", "$adres")You can say I solved the problem myself thanks anyway.acer Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now