yddib Posted March 22, 2008 Share Posted March 22, 2008 I am trying to update a MS Access DB but the only code I could really find was with MySQL. How can I alter it other than adding the DB connection bit at line 9? <html> <body> <?php $id=$_GET['id']; $username="username"; $password="password"; //create an instance of the ADO connection object $conn = new COM ("ADODB.Connection") or die("Cannot start ADO"); //define connection string, specify database driver $connStr = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=c:\wamp\www\employees.mdb"; //Open the connection to the database $conn->open($connStr); echo "Connection Open<br >"; $query=" SELECT * FROM contacts WHERE id='$id'"; $result=mysql_query($query); $num=mysql_numrows($result); $i=0; while ($i < $num) { $first=mysql_result($result,$i,"first"); $last=mysql_result($result,$i,"last"); $phone=mysql_result($result,$i,"phone"); $mobile=mysql_result($result,$i,"mobile"); $fax=mysql_result($result,$i,"fax"); $email=mysql_result($result,$i,"email"); $web=mysql_result($result,$i,"web"); <form action="updated.php" method="post"> <input type="hidden" name="ud_id" value="? echo $id; ?>"> First Name: <input type="text" name="ud_first" value="<? echo $first; ?>"><br> Last Name: <input type="text" name="ud_last" value="<? echo $last; ?>"><br> Phone Number: <input type="text" name="ud_phone" value="<? echo $phone; ?>"><br> Mobile Number: <input type="text" name="ud_mobile" value="<? echo $mobile; ?>"><br> Fax Number: <input type="text" name="ud_fax" value="<? echo $fax; ?>"><br> E-mail Address: <input type="text" name="ud_email" value="<? echo $email; ?>"><br> Web Address: <input type="text" name="ud_web" value="<? echo $web; ?>"><br> <input type="Submit" value="Update"> </form> ++$i; } $ud_id=$_POST['ud_id']; $ud_first=$_POST['ud_first']; $ud_last=$_POST['ud_last']; $ud_phone=$_POST['ud_phone']; $ud_mobile=$_POST['ud_mobile']; $ud_fax=$_POST['ud_fax']; $ud_email=$_POST['ud_email']; $ud_web=$_POST['ud_web']; $username="username"; $password="password"; $database="your_database"; mysql_connect(localhost,$username,$password); $query="UPDATE contacts SET first='$ud_first', last='$ud_last', phone='$ud_phone', mobile='$ud_mobile', fax='$ud_fax', email='$ud_email', web='$ud_web' WHERE id='$ud_id'"; mysql_query($query); echo "Record Updated"; ?> </body> </html> I am only learning php so I know this is probably completely wrong. If anyone can point me in the right direction with it I'd really appreciate it. Link to comment https://forums.phpfreaks.com/topic/97316-mysql-to-access-for-update/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.