sonyangelhan sonyangelhan - 1 year ago 90
PHP Question

Inserting record to MS Access with PHP

so straight to the problem. I'm working with php on a local DSN MS Access database. But the insert function doesnt work, no record added after running the page.

Here are the code.


if (!$conn) {
exit("Connection Failed: " . $conn);


$sql="SELECT * FROM UserInfo";
if (!$user) {
exit("Error in SQL");

while (odbc_fetch_row($user)) {
$lastuser=odbc_result($user, "UserID");
if ($newid < preg_match_all('!\d+!', $lastuser, $lastuserint)) {



$sql1="INSERT INTO UserInfo (UserID, UserName, Password, Birthday, Gender, Phone, Address, CompanyID, Balance) VALUES ('$userid','$username','$password','$birthday','$gender','$phone','$address','$comid','$balance')";
echo $result;

/*-- header("Location: home.php");--*/


Thanks in advance!

Answer Source

I'm not sure but the SQL command seems messy. Try something like this:

`INSERT INTO UserInfo (userid, username, ...) VALUES ('$userid','$username','$birthday','$gender','$phone','$address','$password','$comid','$balance')`

Use your correct field names, of course.

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