RE: [PHP-DB] How to access a MS Access DB
Hello, I'm new to this list and saw a past discussion in mid-Feb. about how to access an MS Access DB. I have Apache and PHP installed on my PC running XP Professional. I created a system DSN and got past the odbc_connect but it died in the odbc_prepare statement. Error message: Warning: odbc_prepare(): supplied argument is not a valid ODBC-Link resource in c:\perl\htdocs\test2.php on line 20 cannot prepare result Here's my code (w/username and password changed): $connection = odbc_connect("mctadb", "username", "password") || die("cannot open database"); $sql = "SELECT MeeetingTitle, MeetingDate FROM meeting;"; $sql_result = odbc_prepare($connection, $sql) || die("cannot prepare result"); Any help would be greatly appreciated, Beverly Steiner [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Confusing Date...
Doug, I know it works if you send the date as -mm-dd. For example yesterday, March 2, 2003 would be 2003-03-02 -- Beverly Steiner [EMAIL PROTECTED] -Original Message- From: Doug Coning [mailto:[EMAIL PROTECTED] Sent: Monday, March 03, 2003 5:29 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Confusing Date... I have a MySQL column that was set to date. In my PHP page, I have a form and a field called 'Sch_StartDate'. I'm having difficultes understanding how to write to the date column in MySQL. If I send 03/04/02for March 4, 2002, the value that gets stored in the MySQL database is 2003-04-02 for April 2nd, 2003. The field is set to to send as a date: GetSQLValueString($HTTP_POST_VARS['Sch_StartDate'], "date") So how do I send dates to MySQL so that it stores it correctly? Thank you!! Confused, Doug -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Confusing Date...
Doug, Here's an example of how to format the date: $date = "3/2/2003"; $good_date= date("Y-m-d", strtotime($date)); ------ Beverly Steiner [EMAIL PROTECTED] -Original Message- From: Doug Coning [mailto:[EMAIL PROTECTED] Sent: Monday, March 03, 2003 5:38 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Confusing Date... Yes, but not too many people are familiar with enter the year first, followed by the month then the date. Is there a way within PHP to take 03/02/2002 and send it as 2003-03-02. Thanks, Doug Coning - Original Message ----- From: "Beverly Steiner" <[EMAIL PROTECTED]> To: "Doug Coning" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Monday, March 03, 2003 3:35 PM Subject: RE: [PHP-DB] Confusing Date... > Doug, > > I know it works if you send the date as -mm-dd. For example yesterday, > March 2, 2003 would be 2003-03-02 > > -- > Beverly Steiner > [EMAIL PROTECTED] > > > -Original Message- > From: Doug Coning [mailto:[EMAIL PROTECTED] > Sent: Monday, March 03, 2003 5:29 PM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] Confusing Date... > > > I have a MySQL column that was set to date. > > In my PHP page, I have a form and a field called 'Sch_StartDate'. I'm > having difficultes understanding how to write to the date column in MySQL. > If I send 03/04/02for March 4, 2002, the value that gets stored in the > MySQL database is 2003-04-02 for April 2nd, 2003. > > The field is set to to send as a date: > GetSQLValueString($HTTP_POST_VARS['Sch_StartDate'], "date") > > So how do I send dates to MySQL so that it stores it correctly? > > Thank you!! > > Confused, > > Doug > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Update MD5 field
Daniela, Why do you want to keep a calculated field inside your database? -- Beverly Steiner [EMAIL PROTECTED] -Original Message- From: Dani Matielo [mailto:[EMAIL PROTECTED] Sent: Monday, March 03, 2003 10:18 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Update MD5 field Hello, everybody my problem is the following: I just imported a csv file to a MySQL database that contains name and email fields. It has about 9k lines on it and I need a new field that orinally didn't exist called "code" thats suposed to be MD5(name.email) I know how to do this for new data, but I don't know how to update all the old ones I already have there. Thank you in advance, Daniela -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] mysql statement: two tables, two comparisons
J, Try this (it assumes that the softid you want to search for is in the variable $softid): $sql = "SELECT Expert.* FROM Expert LEFT JOIN Apliexpert ON Expert.id = Apliexpert.exptid WHERE Apliexpert.softid = '$softid' ORDER BY Expert.Name"; ---------- Beverly Steiner [EMAIL PROTECTED] -Original Message- From: Jason End [mailto:[EMAIL PROTECTED] Sent: Thursday, March 06, 2003 8:52 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] mysql statement: two tables, two comparisons I'm looking for a mysql select statement that does the following: - Check if the value of each expert.id on the table experts matches a value expt.id in the table apliexpert. - For those values where this is true check whether the softID value for that row matches the variable $softId. - return the names that are left after those 2 filters So for tables: Expert idName 1Peter 2Paul 3Mary 4Frank Apliexpert exptid softid 1 3 2 5 2 8 3 9 3 8 1. If the softID is 2, the select should return: peter, paul, mary and frank (frank will always be returned no matter what, because he isn't in apliexpert) 2. If the softID is 3, the select should return: paul, mary and frank 3. If the softID is 8, the select should return: peter and frank 4. If the softID is 9, the select should return: peter, paul and frank J __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] I need some help with php code please
Stephen, Here's how I did a similar thing for LearnGuitar.net. It enables members to upload songs for their music station. $root_dir = "d:/web/uploaded_songs/"; $folder = "$student_id"; $continue = "yes"; if (!is_dir("$root_dir/$folder")) { //echo "the directory does not exist yet so I'll create it"; if (!mkdir("$root_dir/$folder", "0700")) { echo "Error - couldn't create directory!"; $continue = "no"; echo "got here"; } } $filename = $HTTP_POST_FILES["userfile"]["name"]; $temp_file = $HTTP_POST_FILES["userfile"]["tmp_name"]; $file_type = $HTTP_POST_FILES["userfile"]["type"]; //echo "filename is $filename\n"; if ((is_file("$root_dir/$folder/$filename")) && ($continue == "yes")) { echo "You have already submitted a song with the same file name."; $continue = "no"; } if (($file_type == "audio/mpeg") && ($continue == "yes")) { if (copy($temp_file, "$root_dir/$folder/$filename")) { echo "Thank you for submitting your Song!"; $msg = "$first_name $last_name ($email) submitted a song. Folder/File Name: uploaded_songs/$folder/$filename Name of Song: $song_name Is this song a cover or original? $song_type If original, who wrote the song? $songwriter Musicians: $musicians Is this song copyrighted? $copyrighted Musical Syles: $music_styles"; $mailto = "[EMAIL PROTECTED]"; //$mailto = "[EMAIL PROTECTED]"; $mail_subject = "PGS - song submission from $first_name $last_name"; $from = "From: [EMAIL PROTECTED]"; $replyto = "Reply-to: $mailto\n\n"; // should go to Web site to respond mail($mailto, $mail_subject, $msg, $from, $replyto); } else { echo "Error - There was a problem uploading your file."; $continue = "no"; } } // *** end of if (is_file("$root_dir/$folder/$filename")) *** elseif ($continue == "yes") { echo "The file type is not correct. We only accept MP3 files."; } -- Beverly Steiner [EMAIL PROTECTED] -Original Message- From: Stephen K Knight [mailto:[EMAIL PROTECTED] Sent: Friday, March 07, 2003 12:50 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] I need some help with php code please I am trying to upload an image to my webserver. This is the PHP page that is called from my html page. I am trying to upload the image to my folder called "logos" the direct link would be: C:\Program Files\Apache Group\Apache2\htdocs\logos I am not sure what I am doing wrong in the code below. Can someone please look and help me so that I can upload the image to that folder. Thank you! In Kindness Stephen K Knight \n"; // echo "newname = '" . $newname . "';\n"; // echo "\n"; } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Searchform to results.php
Jonathan, Case make a difference on Unix/Linux machines but not in Windows. On a Unix type machine it is best to name all tables and fields with lowercase letters. If you create a table called Member and have the SQL statement of "SELECT * FROM Member" it will not work because SQL is not case sensitive. In order to do the select you need to quote the table name: "SELECT * FROM 'Member'". Case doesn't matter on Windows. Bev ------ Beverly Steiner [EMAIL PROTECTED] -Original Message- From: Jonathan Villa [mailto:[EMAIL PROTECTED] Sent: Friday, March 07, 2003 1:38 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: RE: [PHP-DB] Searchform to results.php "SELECT .. FROM ".$_POST['searchtype']; I'm not to sure if this is just for easy ready, but I haven't too many instances where the query is in all caps. Anyone, does case matter in a query? ---> Jonathan -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, March 07, 2003 12:32 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: [PHP-DB] Searchform to results.php I have a mysql database named DEALER with tables named by states. My script displays all the data correctly if I manually inculde the FROM "state name".I want to make a form to let someone choose the state and run the query. I have tried and failed can someone show me what I am doing wrong?My searchform: Find a Dealer Search Choose a State: OHIO ALABAMA A snip from my results.php $display) { // Only show 1,2,3,etc. when there are more records found that fit on 1 page// when the page is loaded first... if(empty($pagenr)) { $pagenr = 1; } Would you please help me with my mistakes on line6 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] ODBC
No, that won't work. You need to create a system DSN. Here's what I did to create one. My PC is running Windows XP Professional and I am using Apache 1.3.27. * opened up the control panel * double-clicked Administrative Tools * double-clicked Data Sources (ODBC) * clicked on the System DSN tab * clicked Add... * selected Microsoft Access Driver (*.mdb) from the list * clicked Finish * typed mctadb in Data Source Name * clicked on Select... * selected the MS Access database I wanted to connect to and clicked OK * clicked on Advance... * typed in a Login name then clicked OK * clicked OK in the next 2 windows I could use some help as well. I get connected to the database but get an error when I try to execute a SQL statement on it. The error message I get is: Warning: odbc_exec(): supplied argument is not a valid ODBC-Link resource in c:\program files\apache group\apache\htdocs\test2.php on line 30 cannot prepare result Does anyone know what might be missing? Here's the code from test2.php: $connection = odbc_connect("mctadb", "admin", "") || die("cannot open database"); $sql = "SELECT * FROM Meeting"; $result = odbc_exec($connection, $sql) || die("cannot prepare result"); -- Beverly Steiner [EMAIL PROTECTED] -Original Message- From: Kiswa [mailto:[EMAIL PROTECTED] Sent: Friday, March 07, 2003 3:24 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] ODBC Hi. Is their anyway to connect to a Access Db using only the filesystem like $connect = odbc_connect("\Db\Webdb.mdb", "nobody", "nobody"); thus pointing directly to the file not using drivers??? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Database design
Shaun, I took a quick look at your database layout and noticed that Practice_ID and Clinical_Trial_ID are repeated in the Booking table. This isn't necessary because the Booking table links to the Project table which contains this information. In the Project table, Practice_ID and Clinical_Trial_ID should probably just be foreign keys and not primary keys to that table. Same thing for User_ID and Project_ID in the Booking table. To keep track of the data you will need to create a new table which is linked to the Clinical_Trial table. For instance you could create a table called Clinical_Data which has the following fields: * Clinical_Data_ID (PK) * Clinical_Trial_ID (FK) * Data_Description - field that describes a piece of collected data (e.g. blood pressure before hypnosis) Is the User table where the client information goes? You also need to create a joining table between the User (or whatever table contains the client info.) table and the Clinical_Data table. -- Beverly Steiner [EMAIL PROTECTED] -Original Message- From: shaun [mailto:[EMAIL PROTECTED] Sent: Monday, March 10, 2003 8:53 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Database design Hi, I am creating a database for a web application. The idea for the application is for a company administrator to be able to log into the site and allocate staff to a project which will be a clinical trial at a particular practice. Staff will be able to log in and update the status of the project they are working on and clients will be able to log in and book a member of staff. Administrators will be able to add / edit / delete - staff / clients / clinical trials. Here is my database diagram: http://www.mania.plus.com My problem is each different clinical trail will need to have different data collected for it. How could I handle this in the database model? The administrator would like to be able to edit the data collected for each trial via the site... Any other comments on my database model would be appreciated as this is my weakest area of web development by far! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] problem connecting w/ODBC
Hello, I am having problems accessing a database through ODBC. I first sent an email describing my problems accessing an MS Access database through PHP. Today I installed MySQL. I have no problems accessing my test database with the mysql commands. I downloaded MySQL's ODBC driver. I get the same error message trying to access this database w/ODBC as I did with the MS Access database. I am running Windows XP Professional, PHP 4.3.1, and Apache 1.3.27. Here's my PHP code: $connection = odbc_connect("testmysql", "", "") or die ("Couldn't connect to the server."); $sql = "SELECT * FROM member"; $result = odbc_exec($sql,$connection) or die ("Couldn't execute query"); I get the following error message in my browser: Warning: odbc_exec(): supplied argument is not a valid ODBC-Link resource in c:\program files\apache group\apache\htdocs\test4.php on line 17 Couldn't execute query Anyone have any ideas of what I should do so I can access a database through ODBC? -- Beverly Steiner [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] storing files in database
Michiel, You could try storing them in the longtext (text) or longblob (binary) fields. Search at www.mysql.com for more information about the differences between them. Unless you need to search on the data within MySQL, storing files (especially long ones) in the database usually isn't the best solution. Bev -- Beverly Steiner [EMAIL PROTECTED] -Original Message- From: Michiel van Heusden [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 18, 2003 8:25 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] storing files in database is there any possibility using PHP 4 to store entire files as a database field in a MySQL database? and if so, does anybody know a way, or a tutorial describing this? thanks michiel -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
FW: [PHP-DB] problem connecting w/ODBC
Hello again, Does anyone have suggestions about where I can get an answer to the problems I'm having with ODBC? I've tried using: $cursor = odbc_cursor($connection) || die("cannot create cursor"); and get a similar error: Warning: odbc_cursor(): supplied resource is not a valid ODBC result resource in c:\program files\apache group\apache\htdocs\test4.php on line 13 cannot create cursor Any help would be greatly appreciated. I've been trying unsuccessfully to access to an MS Access database with PHP for weeks now. Any ideas of where I can get the answer? I have posted to the PHP-INST and PHP-DB lists. ------ Beverly Steiner [EMAIL PROTECTED] -Original Message----- From: Beverly Steiner [mailto:[EMAIL PROTECTED] Sent: Friday, March 14, 2003 7:13 PM To: PHPDB Subject: [PHP-DB] problem connecting w/ODBC Hello, I am having problems accessing a database through ODBC. I first sent an email describing my problems accessing an MS Access database through PHP. Today I installed MySQL. I have no problems accessing my test database with the mysql commands. I downloaded MySQL's ODBC driver. I get the same error message trying to access this database w/ODBC as I did with the MS Access database. I am running Windows XP Professional, PHP 4.3.1, and Apache 1.3.27. Here's my PHP code: $connection = odbc_connect("testmysql", "", "") or die ("Couldn't connect to the server."); $sql = "SELECT * FROM member"; $result = odbc_exec($sql,$connection) or die ("Couldn't execute query"); I get the following error message in my browser: Warning: odbc_exec(): supplied argument is not a valid ODBC-Link resource in c:\program files\apache group\apache\htdocs\test4.php on line 17 Couldn't execute query Anyone have any ideas of what I should do so I can access a database through ODBC? -- Beverly Steiner [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Not seeing whats wrong with code
Mike, Try mysql_fetch_array instead of mysql_fetch_row -- Beverly Steiner [EMAIL PROTECTED] -Original Message- From: Mike Delorme [mailto:[EMAIL PROTECTED] Sent: Thursday, March 20, 2003 12:01 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Not seeing whats wrong with code Hello, I am trying to write a script that conects to mysql, then SHA database. Then I need to list ALL the rows of table members. It sais there is a error on line 18. The while statement is on line 18, and I cant firgure out whats wrong with it: Thanks, Mike Delorme -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] problem connecting w/ODBC
Problem fixed! Thank you to David who pointed out that I had my variables switched in the in the odbc_exec and odbc_cursor lines. For ODBC, the connection variable comes first (the opposite of MySQL). Bev -- Beverly Steiner [EMAIL PROTECTED] -Original Message- From: Beverly Steiner [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 18, 2003 1:58 PM To: PHPDB Subject: FW: [PHP-DB] problem connecting w/ODBC Hello again, Does anyone have suggestions about where I can get an answer to the problems I'm having with ODBC? I've tried using: $cursor = odbc_cursor($connection) || die("cannot create cursor"); and get a similar error: Warning: odbc_cursor(): supplied resource is not a valid ODBC result resource in c:\program files\apache group\apache\htdocs\test4.php on line 13 cannot create cursor Any help would be greatly appreciated. I've been trying unsuccessfully to access to an MS Access database with PHP for weeks now. Any ideas of where I can get the answer? I have posted to the PHP-INST and PHP-DB lists. ------ Beverly Steiner [EMAIL PROTECTED] -Original Message----- From: Beverly Steiner [mailto:[EMAIL PROTECTED] Sent: Friday, March 14, 2003 7:13 PM To: PHPDB Subject: [PHP-DB] problem connecting w/ODBC Hello, I am having problems accessing a database through ODBC. I first sent an email describing my problems accessing an MS Access database through PHP. Today I installed MySQL. I have no problems accessing my test database with the mysql commands. I downloaded MySQL's ODBC driver. I get the same error message trying to access this database w/ODBC as I did with the MS Access database. I am running Windows XP Professional, PHP 4.3.1, and Apache 1.3.27. Here's my PHP code: $connection = odbc_connect("testmysql", "", "") or die ("Couldn't connect to the server."); $sql = "SELECT * FROM member"; $result = odbc_exec($sql,$connection) or die ("Couldn't execute query"); I get the following error message in my browser: Warning: odbc_exec(): supplied argument is not a valid ODBC-Link resource in c:\program files\apache group\apache\htdocs\test4.php on line 17 Couldn't execute query Anyone have any ideas of what I should do so I can access a database through ODBC? -- Beverly Steiner [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php