Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Insert Into Microsoft Access Table Using ODBC


The following lines of code don't return an error but they also do not insert the row into the database:

$SQLText="Insert into member (MailingID, MemberID, [File As], EMail, LetterID, AudienceID, DateSent, Sent) Select $MailingCode, $row[0], '".$row[5]."', '".$row[6]."', $LIDToInsert, $AIDToInsert, '".$DateSent."', 1;";

print '<br>'.$SQLText;

$rs_upd=odbc_exec($link, $SQLText);

if (!$rs_upd) die("Couldn't update database");

I've tested the resulting $SQLText string in Access directly and it works find there so this must be a PHP or ODBC issue.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
SQL Error: [Microsoft][ODBC Microsoft Access Driver] Too Few Parameters
I'm trying to execute the following SQL statement and get the following error.

SELECT DomainNames.DomainName FROM DomainNames WHERE DomainNames.DomainName Like "*ab*" ORDER BY DomainNames.DomainName

SQL error: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1., SQL state 07001 in SQLExecDirect

I'm running PHP4, Apache 1.3.12 (Win32) and connecting to an Access database on a Win2K box.

Odbc_exec(): SQL Error: [Microsoft][ODBC Microsoft Access Driver]
i am trying to write to the database through odbc. i get the following error:

Warning: odbc_exec(): SQL error: [Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query., SQL state S1000 in SQLExecDirect in c:inetpubwwwroot514VIP_SurveyProcess.php on line 41

my directory has read/write permissions why am i getting this? here is the code as an example:
...
$x = 10;
$querySet = "UPDATE Survey SET $rdoOption = $x";
odbc_exec($objConn, $querySet);
...

MS Access And Php- Insert Row In A Table
I am not able to insert a row through a form in my database which is in Access.Please see my code below and help..Select works O.K. but inserting through form is a problem.This is form1.php.here I am inserting the values.This form has action process.php......

Warning: SQL Error: [Microsoft][ODBC Driver Manager]
Cannot get an ODBC (or MSSQL) connection to MS Sql Server 7. Using a system datasource and it connects fine, but PHP does not like it. I've had no problem with NT4 but Win2K is another story...

Warning: SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in c:inetpubwwwrootindex.php on line 8

PHP And Microsoft Access
Is it possible to use php to interface with an ms access database?

Our current database (customers, suppliers etc) is in ms access format and we need to run msaccess. I dont feel like converting the whole database over to mysql and we still need the original system, the idea will be that the staff can access the database on the road thru a webpage.

Exporting To Microsoft Access
I have a PHP website with a mySQL database and a client wants to be able to see the database on his computer using Microsoft Access.

I would like to be able to make a special backdoor section for him, where he enters his username and password and is given a link which will make take a snapshot of the mySQL database and convert it to a Microsoft Access database which he can download to his computer.

Is this possible?

Since he isn't very computer savvy I need a way as user friendly as possible to let him download the database and view on his local computer.

Microsoft Access -> PhpMyAdmin
Alright, so what’s going on is that I have coded an entire website with in mind to have an Access Database. So everything works great...

But now I am faced with the problem that I have to have my webpage work with phpMyAdmin, which works completely differently in running my sql statements and everything, ie: ->EOF, select statement, etc...

Is there a way for me to have a smooth transition for my code to work with phpMyAdmin instead of Access at the moment, because recoding all of this means an enormous amount of work with not much free time left on my hands. Code:

Microsoft Access Dropdown List
l am building a new site using PHP which has a lot of pages pulling from an Access Database. I would like to have a dropdown list that pulls exhibitions from the database and then when the user selects one it shows the rest of the details from DB just below the dropdown list, hope that makes sense. Code:

Inserting A Date Into A Microsoft Access 97 Database
I was wondering if anyone could help me insert a short date into microsoft access 97 using php? i can insert text no problem but i can't seem to be able to insert a date properly. i have been using

//$date = "#" . "$sqlmonth" . "1" . "$cboyear" . "#";

$strSQL = "INSERT INTO tblSupport (tDate) VALUES ($date)";
$result = odbc_exec($connect, $strSQL);

Note: i can insert a date if i hard code it like putting in #01

PHP To MS Access Via ODBC
Newbie here and relative newbie to PHP.

Mentioned this on on a totally different forum so sorry if you get
this twice. I'm trying to use php to write to an access db and
haven't had any luck. Surfed the archives and tried the examples for
insert into via odbc from phpbuilder but it never writes the data to
the db.

The forms draw up properly and when I hit the submit button it goes to
the page that is supposed to run the code to write to a db but it
doesn't save. Created a system dsn via the examples as well. Have
Apache and php 5 installed on my machine.

Does anyone have examples of insert into from PHP to Access? I know
SQL Server is more stable but they've already been waiting forever
before I took the job and the project is already build in Access.
Plus this is for a low hit/ low volume survey type thing.

I don't get any error messages. It just doesn't store the data.

PHP & ODBC & MS Access
Can anybody link me to some good tutorials regarding using php to extract and retrive data etc from ms access please? I've followed the tutorial about retrieving data and setting up OBDC on this site and it was very helpful although i'd like to expand my knowledge.

My next task would be to learn how to add data from a web form into ms access using php. If there aren't any good tutorials perhaps someone knows a good example they could post here?

Using An Access Db From Php On Linux? Odbc?
I have my site running on a linux server, and I want to pull data from an access db on a windows server. I have ODBC set up under linux, and can connect to the mssql server that way, is there a free linux odbc driver for access?

Communicate With Access Database Using ODBC?
has anyone has any source / idea that php (under windows environment) could communicate with acess database by using ODBC?

Images In Access-DB, Display Via ODBC, SQL,
I'm trying to display an image that is stored in an MS-Access97 Database via ODBC, SQL and
PHP3 on a WinNT4.0 System (SP5). The Image (a tiff-file) is stored in the Access-DB as an OLE-Object. From an HTML-Page, I call the following php3-script. In the php3.ini-file, all "magic_quotes_" are disabled. Code:

MSSQL Access Via PDO And Windows ODBC
I'm running a "Windows Server 2003" with "MS SQL 2000" IIS and PHP5.1 as
test environment for my project. I would like to access my MSSQL-Server
via Windows ODBC and PDO. I created a System DSN an i enabled the PDO
extension in my php.ini. But the following code snippet keeps failing:

<?php
try
{
$DB = new PDO("odbc:LocalServer");
}
catch (PDOException $e)
{
echo $e->getMessage() . "<br>";
exit;
}
?>

Here is the error message:

"could not find driver"

Weird Problem With PDO/ODBC And Access
I have an Access database and a table. One of the columns was a memo
field. If I execute a 'select * from table', all the rows would be
retrieved but the columns after the memo column had null data.

If I moved the memo field to the end and executed the same SQL the data
was retrieved propery.

Also if I specified the column name by itself (E.g. select phone from
table' ), the data was retrieved.

Has anyone seen this kind of problem with any other databases where a
memo field must be the last one?

PHP ODBC Update Query To Access
For some reason I am getting a datatype mismatch on the following SQL query and I do not understand why because the field datatype is number in the access database and the update query is using a number to update to that field? PHP Code:

ODBC Query Of Access 2000 Db Using LIKE
Attempting to query MS Access database with the ODBC drivers for PHP. When
using the LIKE statement no records are returned.

Example:

$query = " Select * From Dispatch Where Customer Like '*A*' ";
$result = odbc_prepare($db,$query);
odbc_execute($result);

Does anyone out there know the syntax that I should be using for the Like
statement in the Where clause? When I do a normal query, it works
fine....Just using wildcards it does not work....

Prevent SQL Injection In ODBC And MS Access?
I'm on a GoDaddy Windows hosting using PHP and MS Access. It is well documented how to prevent SQL injection with MySQL, but how do one prevent SQL injection with ODBC and MS Access?

Any suggestions would be much appreciated. Seems like Access with PHP is fairly rare and not much information on the net is written about it.

MS Access + ODBC Links On Remote Servers
Has anyone ever figured out why an ODBC link, via PHP, will only connect properly if the DSN and .mdb files live on the same box as the web server? For some reason, the ODBC functions seem to ignore mapped network drives and even UNC path names. Anyone know of a PEAR module or third party class that will do the job?

Weird ODBC Access Error With String Concatenation
trying to connect to access via ODBC. The
following query works fine if run from access:

SELECT spchacti.FNAME AS firstname, spchacti.
LNAME AS lastname, [Spchacti]![ADDR] & " " &
[Spchacti]![ADD1] AS address, "sc" AS source
FROM spchacti;

but from PHP (through PEAR DB), I get the
following error:

[nativecode=07001 [Microsoft][ODBC Microsoft
Access Driver] Too few parameters. Expected 1.]

MS says this is when you reference a non
existant column, but this isn't the problem
because even this query doesn't work:

SELECT add1 & " asasas" from spchacti Any
concatenation seems to break it, but it always
works from access. Odly, if you add Trim()
around a field, it works, so I thought I would try
Trim(Addr1) & Trim(" ,") & Trim(Add2) as
address but this breaks due to the middle one,
using Trim on a string instead of a field causes it
to break. Weird, and very VERY frusterating
because it all works peachy in access.

Grab Data From A Table, Echo, Then Insert It Into A New Table...
I'm trying to do is count the number of times usernames shows up in a table. I then want to reinsert that information into a different table with the Username in column1 & the occurrences in column2 for every user that is echoed on the page. Code:

Update Table While Insert Data To Another Table
it seem like mine coding din work.
[php]<?

include("checkin.html");
$conn=mysql_connect('localhost','root','') or die ('Could not connect to server');
$today = date("Y.m.d");
mysql_select_db('hms', $conn);

$ok = mysql_query("INSERT INTO check_in(ID,room_no,datein)values ('$ID','$room','$today')", $conn);

if( $ok ){

$up = mysql_query("UPDATE studtable SET checked = 'checkin' where [ID] = '%ID');

if(mysql_affected_rows( $up ) == 1)
{
echo'Checked IN!'
}else { echo'No such student to check in' }}
else { echo'Check In FAILED, please check again'}?>[php]

Insert Fails On Access That I Know Works...
I use PHP to write my form data to MySQL.

I have a database with about ten tables. I'm trying to fill one table with
some dummy data (its a contact manager table holding names of people,
addresses and whatever but I'm createing random values for the moment). The
insert fails telling me that access is denied - however I use the exact same
username/password/database name/host name on the other tables, and the
insert and updates work just fine.

I know this sounds odd - but is there any other reason as to why I might get
the access denied message, other than what I assume should be just for an
invalid username/password?

The following is a customized output of my error:

Can't Insert Record Into Access Database
I'm trying to create a registration/login script using Access 2003. I'm using ADOdb to connect through ODBC.

The problem is that I get the little custom error Could Not Connect to Server when I try to insert a record, yet when I use the form with a username I inserted through Access it reads it just fine and returns if the username has been used. Also if I removed line line 23 or die('<b>Could Not Connect to Server</b>'); and it'll complete the script, but it won't insert the record. Code:

Insert Into Table Using For Loop
i managed to get bits a pieces and managed to get this script to nearly work. I put together this script which a)gets a no. of fields to create 2) creates those fields 3) on submission it checks for blank fields & may display error msg 4) also it checks in the db for duplicates & may display error msg 5) if all good it submits to db.

Here comes my dilemma. 1, 2, 3 and 4 work fine however the final part 5 doesnt work at all. 5 works if 3 and 4 are taken away for some reason. I am sure there i am missing something. Can someone please take on the challenge and direct me to where i could be going wrong. PHP Code:

How To Get Last Insert ID In MYSQL Table
May I know how to retrieve the last inserted ....

Insert Data To A Table
I just can't figure out why it isn't sending the data to the table, I've check the names over and over, all the info is parsed correctly, but it falls flat at: $result = mysql_query($sql);

Switch And Insert Into Table
I want to build a questionnaire with php. My problem is that the second page where i insert the results into the database doesnt work. Code:

Mulitiple Table Insert
I have a table that when you add a new department it will add the name to the table and assign the row and id based on an auto_increment column. From there you need to get the value of the last insert id. SO what I did was use the msql_insert_is() function. and assigned it to a variable.

I then used that variable in my next query because this vaule is a forigen key in another table. Here is my code it should be exectued if you where to post this page with the value of $department_id = "" then the section of script in question will execture. Essentially need it to grab this id number and then place it into 2 more insert statements that should execute immediately after the first insert statement.

Then only insert id that I would need is the one produced in the first insert statement what an auto increment value is assigned to the same table as the department_name Code:

Insert To One Table, Update To Another
I'm trying to do two queries at once utilizing data from a form. I'm creating a new row in one table, and I need to reflect the ID number and other supplementary data to an existing record in another table. Is there a way to string two queries together so they execute at the same time? Here's what I've been trying so far: Code:

Multiple Table Insert
I have a table that when you add a new department it will add the name to the table and assign the row and id based on an auto_increment column. From there you need to get the value of the last insert id. SO what I did was use the msql_insert_is() function. and assigned it to a variable.

I then used that variable in my next query because this vaule is a forigen key in another table. Here is my code it should be exectued if you where to post this page with the value of $department_id = "" then the section of script in question will execture. Essentially need it to grab this id number and then place it into 2 more insert statements that should execute immediately after the first insert statement.

Then only insert id that I would need is the one produced in the first insert statement what an auto increment value is assigned to the same table as the department_name Code:

Insert Into Table Via Assoc Array
I am trying to populate data from an array into a table, but i cant figure out what i am doing wrong.

//mysql query
$sql = "SELECT charge_location.dept_code, charge_location.week,
Sum(charge_location.total_hrs_paid) AS sum_of_total_hrs_paid,
Sum(charge_location.hrs_non_chargeable) AS sum_of_hrs_non_chargeable
FROM charge_location
GROUP BY charge_location.dept_code, charge_location.week";

$result = mysql_query($sql);
$num_results = mysql_num_rows($result);

//populate the stats_table
for($i=0; $i<$num_results; $i++){
$row = mysql_fetch_array($result);
mysql_query("insert into stats_summary values(
($row[dept_code]),
($row[week]),
($row[sum_of_total_hrs_paid]),
($row[sum_of_hrs_non_chargeable]))
");
}

PS i get no errors when it executes, just fails to populate the table.

Using An Array To Insert Data Into A Table.
This works:
$col1 = 2;
$col2 = 2;
$col3 = 2;
$col4 = 2;
$query = "INSERT INTO test (a,b,c,d) VALUES ($col1,$col2,$col3,$col4)";

and this does not

$col = array(2,2,2,2);

$query = "INSERT INTO test (a,b,c,d) VALUES ($col)";

How Do You Insert A Value From Drop Down List To SQL Table?
I am a bit new to PHP and SQL so this may seem like a dumb question.

I have already created a drop down list as part of a form which is
automatically populated with values taken from a separate database. When a
user goes onto this page and either leaves the default value or selects a
value from the drop down list and presses the submit button, I would like
that selected value to be stored into a database which I have already
created in SQL.

Just to let you know that I can do the above using a text field but just
don't know how to do it with drop down list.

If your going to explain any coding then it may help if I give you the names
of certain items that are involved.

Database is called "Company"
Field within database is called "Name"

Multiple Table Insert With Php Mysql
I am having and issue getting this code working. It seems rather simple but I cannot figure out why only one sql statement is exectuing and the insert statements the other 2 are not exectuting and updating the other 2 tables. I need to do this. I need to update one table, then from that I need to retrieve the mysql_insert_id or just get the id of the last record in the tabe.

There is an auto increment column that gets assigned a unique id each time a record is inserted. I need this id number then I need it to place data into 2 other tables that will use this value as a reference. here is the code:

Insert New Row In Table After 5 Lines - Detect Whole Number?
I have a script that loops through an image directory to create a table of thumbnails. I want to start a new row after every fifth thumbnail. I assumed there was a function which identified whole numbers, but alas, there doesn't seem to be. How do I produce a short version of my long, working version below. PHP Code:

Insert Empy Variable Into Mysql Table
I've got a form in which a couple of the address fields can be empty when the form is submitted... I haven't actually managed to get the Insert statement to work yet (see other post..), but I know this seems to also be causing problems. I have set up the table fields for these 2 address form fields to be Yes under the NULL column, but it still gives the almighty:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' , London, W1, UK, 9991, 007, 'warstormer@hotmail.com'' at line 1 Code:

Php Script To Perform Mysql Table Insert
I'm trying to have my php script insert into 2 tables at once, it's for a picture database.  Is it actually possible to insert into 2 tables at once?  If so what would the sql statement look like. 

Multiple Table Insert From Tab Delimited File
I have a page I'm coding for batch updates from a tab delimited file. Each row has data that has to be checked against and inserted/updated on different tables in my mySQL database.

How would I go about parsing through the tab delimited file and then storing data between the tabs in order to insert individually into separate tables??

Here's what I have so far...

$contents = file('/myfile.txt');

for ($i=0; $i<sizeof($contents); $i++) {

$line = trim($contents[$i]);
$arr = explode(" ", $line);

$line[$i] = array('ID' => $arr[0], 'Record_Type' => $arr[1], 'First_Name' => $arr[2], 'MI' => $arr[3], 'Last_Name' =>
$arr[4], 'Firm' => $arr[5], 'Address' => $arr[6], 'type' => rtrim($arr[13]));

I need to take the different columns.. ID, Record_Type, etc. and update different tables with each value where the IDs match.

Table Name In Ms Access Database
I'd like to know how can i get and store the table names of an ms access database. I use odbc_result_all but i don't know how to exctract and store information about the table name.

Multi Table Insert Delete Select Function Needed.
I am going nuts here and I know with all the functions out there, there must be an easier way to do this. Maybe someone can point me to the right tutorial or even show me how to do this.

I have a $main_id and many $sub_id tables and like to “SELECT to view” INSERT and DELETE those. UPDATE must not be but would be nice.
Here is how it looks:

How To Access And Modify And Add Records In MySQL Table From A Windows Client?
The MySQL table is located in a Linux Server OS, so I need the
information from that table for updating Paradox tables in Windows OS.
If a PHP program in the Linux Server can save a file with the
information I need, can I make a PHP program in Windows OS to get the
saved file or even better, to access the table in the Linus Server OS?...

PHP On Microsoft-IIS/6.0
Is it possible to make IIS parse .html files the same way as Apache does
with AddType application/x-httpd-php .html in .htaccess?

Microsoft SQL Connection
I am looking to have a php page that will have a required include of a
config file with the MS SQL connection creation. I want to have a form
that saves into a MS SQL database. Could call out to a stored
procedure or have inline code in the php page.

Anyone have examples or generic sample code I can use?

PHP With Microsoft Sharepoint ?
I would like to ask if I can synchronize Sharepoint Services with my PHP
website?

Hint: I think it can be done by XML as a bridge.. but I am not sure and
wanna be sure.

PHP And Microsoft Word
I have users who can sent a Word document as an attachment to an email
from a Microsoft-rich environment. I would like to be able to
"capture" that attachment as a blob and deposit it into a mysql
database. I am not sure how to do the capture.

PHP To Microsoft Outlook
Is it possible to send meeting notifications to microsoft outlook through php? I guess it would be sort of an e-mail sent to an individual telling them they have been invited to attend an event and the event info is automatically added to thier outlook calender or something?

Microsoft Exchange Server
Do any of you know a free PHP script that does the same stuff as Microsoft
Exchange Server?


Copyright © 2005-08 www.BigResource.com, All rights reserved