Hi,
I was wondering if someone knows the answer.
I just installed Wamp with: Apache Version : 2.2.8 PHP Version : 5.2.5 and
phpMyAdmin - 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 query
This 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>
</html
This 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