[PHP-DB] Sessions
Hi, all First of all, I apologize if this is a dump question but I can't find the answer. I'm trying to use sessions to keep the information about user and password in a database driven web application. I am trying with a simple web page but I can't make it work correctly. Help me, please. Environment: Red Hat Linux 7.2, Apache 1.3.20, PHP 4.0.6 Web pages: Page 1: web page with a form asking for a user name and password. Page 2: php page to validate the user name and pass and register them as session variables. Page 3: php page to show the user name and pass introduced. Code: Page 2: ? session_start(); ? ? $sessionid = session_id(); ? ? session_register ( $usr, $password, $sessionid); ? Page 3 ? session_start(); ? ? echo $GLOBALS[usr]; ? ? echo $GLOBALS[password]; ? Results: Page 2: Opening the session Warning: Cannot send session cookie - headers already sent by (output started at /var/www/html/sigma/agenda/index.php:13) in /var/www/html/sigma/agenda/index.php on line 27 Warning: Cannot send session cache limiter - headers already sent (output started at /var/www/html/sigma/agenda/index.php:13) in /var/www/html/sigma/agenda/index.php on line 27 Page 3: the same warnings and the value of the session variables is lost. Here are my settings for sessions in the php.ini, It could be a configuration mistake. session.save_handler = files session.save_path = /tmp session.use_cookies = 1 session.name = PHPSESSID session.auto_start = 0 session.cookie_lifetime = 0 session.cookie_path = / session.cookie_domain = session.serialize_handler = php session.gc_probability = 1 session.gc_maxlifetime = 1440 session.referer_check = session.entropy_length = 0 session.entropy_file = session.cache_limiter = nocache session.cache_expire = 180 session.use_trans_sid = 1 I know that questions related to sessions had been treated in the list before but I can't find the answer to this, so I think this must be a very stupid question, sorry. Thank you very much in advanced. -- - Álvar Muñoz Sánchez Oficina Verde - UPV Información y Documentación - -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] query from two tables
Hi Balazs, The situation: I have 2 tables in an adverising site. In one table, i have the cities used by advertisers, and in the other there are the ads.This ad table has a field which refers to the id of the city in that table. The problem: what mysql method should i use if i want to order the query by cities? I have tried multiple selection like select ads.*, cities.* from ads, cities , but it returns a nonsense. Any help would be appreciated Are you looking for an ORDER BY clause to sequence the rows of the resultset? =dn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Oracle connection
I'm trying to connect to a Oracle database but i'm receiving the following error message in the browser: Fatal error: Call to undefined function: ora_logon() in /home/httpd/html/restrito/testes/teste_bd.php on line 17 I'm starting to learn PHP now, so I don't know what does it means or what I need to do to make it work
Re: [PHP-DB] Re: FIle Uploading to database
Hey did you get it to work yet?!?! Dan On Sunday, February 3, 2002, at 09:08 PM, [EMAIL PROTECTED] wrote: Umm.. SET parameter is for the UPDATE query Adam Royle [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... You missed the SET parameter in your query... example is below... $query = INSERT INTO Canidate SET (FirstName, LastName, Indus... Adam -Original Message- From: Todd Williamsen [mailto:[EMAIL PROTECTED]] Sent: Monday, February 04, 2002 11:06 AM To: [EMAIL PROTECTED] Subject: Re: FIle Uploading to database Well... thanks to Dan Burner for the script... BUT I cannot get this friggin INSERT statement to execute.. which craps out.. I cannot figure it out. I have been staring at it for about an hour and I still cannot figure it out here it is: $db = @mysql_select_db($db_name, $connection) or die(Could not select database); $query = INSERT INTO Canidate(FirstName, LastName, Industry, Address1, Address2, City, State, Zip, LocationPref, Phone, Email, ResumeUp) VALUES ('$FirstName', '$LastName', '$Industry' '$Address1', 'Address2', '$City', '$State', '$Zip', '$LocationPref', '$Phone', '$Email', '$ResumeUp2'); $result = @mysql_query($query, $connection) or die(could not execute query); $pat = array(#, @, *, , %, @,$,',`); $w= '_'; $ResumeUp2 = str_replace ($pat, $w, stripslashes($ResumeUp)); exec(cp '$ResumeUp' '/resumes/$ResumeUp2'); ? it errors out on the $result could not execute query Let me know if you need more info! Thank you! -- 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
Morten, ODBC stands for Open Database Connectivity. It's a connection layer (API) that is non-database-specific. This removes application dependence on one particular database, e.g. using ODBC instead of native functions allows you to write your application against MySQL and then deploy on Oracle, for instance. On Linux and other *nix flavors, connecting to databases with ODBC using PHP requires that PHP be compiled with an ODBC Driver Manager, and that ODBC Drivers be installed. A HOWTO is available at www.iodbc.org as well as an Open Source Driver Manager and free commercial driver downloads. On Windows, only drivers need to be installed, as the Driver Manager is present (MDAC or ODBC Administrator) and PHP builds for Windows can use this by default. Hope this helps! Best regards, Andrew Hill Director of Technology Evangelism OpenLink Software http://www.openlinksw.com Universal Data Access Data Integration Technology Providers office:781.273.0900 x 27 mobile:781.608.4217 -Original Message- From: Morten Nielsen [mailto:[EMAIL PROTECTED]] Sent: Saturday, February 02, 2002 11:45 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] ODBC Hi, Could anybody explain to me what ODBC is. Should I install it when I use mySQL? Thanks, Morten -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] query from two tables
Since you gave no real details of your table structure, I'll conjecture. Assume city table and advert table is defined as: CREATE TABLE city ( city_id int not null, auto_increment, city_name varchar(50) default ) CREATE TABLE adverts ( ad_id int not null auto_increment, ad_text varchar(200) default , city_id int not null ) SELECT c.city_name, a.ad_text FROM adverts a LEFT JOIN city c using(city_id) ORDER BY city; This will list every advert. Where an advert has no city. the city_name will display as NULL. To find cities with no adverts: SELECT c.city_name, a.ad_text FROM city c LEFT JOIN adverts a using(city_id) ORDER BY city; -Original Message- From: Ivan Balazs [mailto:[EMAIL PROTECTED]] Sent: Monday, February 04, 2002 6:26 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] query from two tables Hi! The situation: I have 2 tables in an adverising site. In one table, i have the cities used by advertisers, and in the other there are the ads.This ad table has a field which refers to the id of the city in that table. The problem: what mysql method should i use if i want to order the query by cities? I have tried multiple selection like select ads.*, cities.* from ads, cities , but it returns a nonsense. Any help would be appreciated Balazs -- 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] Re: FIle Uploading to database
Make sure the path name is correct Let's say you compiled apache with this prefix /web you must have the full path name to work...like this exec(cp '$ResumeUp' '/web/htdocs/resumes/$ResumeUp2'); Also check permissions... I think that was my problem at first too!!! You can also do debug the script. Like this echo $ResumeUp; That should print the tmp file you form created... Let me know... Once this pasts...It works really well... Dan On Monday, February 4, 2002, at 09:35 AM, [EMAIL PROTECTED] wrote: The INSERT statement works fine now, but the file isn't being uploaded. I cannot figure out why -Original Message- From: Dan Brunner [mailto:[EMAIL PROTECTED]] Sent: Monday, February 04, 2002 7:54 AM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Re: FIle Uploading to database Hey did you get it to work yet?!?! Dan On Sunday, February 3, 2002, at 09:08 PM, [EMAIL PROTECTED] wrote: Umm.. SET parameter is for the UPDATE query Adam Royle [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... You missed the SET parameter in your query... example is below... $query = INSERT INTO Canidate SET (FirstName, LastName, Indus... Adam -Original Message- From: Todd Williamsen [mailto:[EMAIL PROTECTED]] Sent: Monday, February 04, 2002 11:06 AM To: [EMAIL PROTECTED] Subject: Re: FIle Uploading to database Well... thanks to Dan Burner for the script... BUT I cannot get this friggin INSERT statement to execute.. which craps out.. I cannot figure it out. I have been staring at it for about an hour and I still cannot figure it out here it is: $db = @mysql_select_db($db_name, $connection) or die(Could not select database); $query = INSERT INTO Canidate(FirstName, LastName, Industry, Address1, Address2, City, State, Zip, LocationPref, Phone, Email, ResumeUp) VALUES ('$FirstName', '$LastName', '$Industry' '$Address1', 'Address2', '$City', '$State', '$Zip', '$LocationPref', '$Phone', '$Email', '$ResumeUp2'); $result = @mysql_query($query, $connection) or die(could not execute query); $pat = array(#, @, *, , %, @,$,',`); $w= '_'; $ResumeUp2 = str_replace ($pat, $w, stripslashes($ResumeUp)); exec(cp '$ResumeUp' '/resumes/$ResumeUp2'); ? it errors out on the $result could not execute query Let me know if you need more info! Thank you! -- 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] MySQL
Hi, Is there an easy way to see the data in a table? I made a table that contains information about people. How do I see/change the contenst of the table? Thanks, Morten -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL
Easiest way is to download and install phpMyAdmin. http://phpmyadmin.sourceforge.net/ HTH Richy -Original Message- From: Morten Nielsen [SMTP:[EMAIL PROTECTED]] Sent: 04 February 2002 16:34 To: [EMAIL PROTECTED] Subject:[PHP-DB] MySQL Hi, Is there an easy way to see the data in a table? I made a table that contains information about people. How do I see/change the contenst of the table? Thanks, Morten -- 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
Go download PHPMyAdmin. - Original Message - From: Morten Nielsen [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, February 04, 2002 8:34 AM Subject: [PHP-DB] MySQL Hi, Is there an easy way to see the data in a table? I made a table that contains information about people. How do I see/change the contenst of the table? Thanks, Morten -- 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
--- Excellence in internet and open source software --- Sunmaia www.sunmaia.net [EMAIL PROTECTED] tel. 0121-242-1473 --- -Original Message- From: Peter Lovatt [mailto:[EMAIL PROTECTED]] Sent: 04 February 2002 16:30 To: Morten Nielsen Subject: RE: [PHP-DB] MySQL phpMyAdmin! http://phpwizard.net/projects/phpMyAdmin/ HTH Peter --- Excellence in internet and open source software --- Sunmaia www.sunmaia.net [EMAIL PROTECTED] tel. 0121-242-1473 --- -Original Message- From: Morten Nielsen [mailto:[EMAIL PROTECTED]] Sent: 04 February 2002 16:34 To: [EMAIL PROTECTED] Subject: [PHP-DB] MySQL Hi, Is there an easy way to see the data in a table? I made a table that contains information about people. How do I see/change the contenst of the table? Thanks, Morten -- 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] Combined sql statement
I would like to know how to have a php script loop through two different sql statements and use one according to a yes or no answer. I am still kinda new to php and I already have my sql statements, but I dont know how to use php to tell it to use one of the other. My sql statements are as follows... $sql = INSERT INTO $table_name (our_serv) VALUES (\$our_serv\) ; $sql = UPDATE $table_name SET our_serv=\$our_serv\; How can I get it to pick one of these... for instance if there is no entry in the unique table to enter one using the first sql statement, or if there is already an entry to simply update and overwrite the current table entry. Any help would be appriciated and if you could please document it so I understand and dont have to ask again. Thanks, jas WOW, your neat -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Poisoned Persistent OCI8 Connections
Unfortunetly I'm stuck with the Oracle setup I've been dealt. It's an already deployed production-level server and is not going to change any time soon. So, I need to find some other way of getting around this using PHP and maybe some other magic. If anyone has any ideas, please let me know. Thank you, Hans John Lim wrote: Hi, I don't have a direct solution to the problem, but I would use Oracle's Multi-Threaded Server and switch to using normal non-persistent PHP connections. Eg. rely on Oracle to do the connection pooling instead of PHP. My benchmarks suggest that this is quite an efficient method of connecting for short queries. Regards, John Hz11 [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I have PHP 4.0.6 compiled as an Apache 1.3.20 module with OCI8 and MySQL on RedHat 6.2. I use persistent connections with OCI8 to avoid the costly connection construction for Oracle for each request. However, I notice that these persistent connections get poisoned under certain circumstances. What I mean by this is this: Since each persistent connection stays with it's corresponding Apache process, if the database happens to be down when a request comes in, the persistent connection that is used throws an ORA-03113. However, even when the database comes back, the persistent connection still thinks the database is down somehow, and will continue to throw the ORA-03113 error. As a result, if a request happens to hit the poisoned Apache process, it appears the database is down. If a request hits another Apache process, all is OK. So far, the only way I've seen to deal this is to restart Apache, and have the persistent connections build up again. Obviously, this is not a good thing, and if the database should go down again, the persistent connections get poisoned again, and the cycle begins. How can this be dealt with? Any help would be great, as customers don't like having to refresh the page to avoid error messages. If any more info or clarification is needed please contact me. Thank you, Hans -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MySQL connect
Hi all, Ok I am learning this on my own but I could use some help. I have started these two pages test.php and config.php here is the code: test.php ? // include the database configuration include config.php; // connect to database mysql_connect($db[host],$db[user],$db[password],$db[database]) or die (sorry not successful); // if no connect then exit exit; // if connect successful echo (you have connected); ? config.php ? // database config $db[host] = localhost; $db[user] = me; $db[password] = mypassword; $db[database] = mydb; ? All I'm trying to do is successfully connect to the database but it returns sorry not successful. What have I done wrong? I have gone straight from the php pocket reference manual and it doesn't work. Would someone please explain what has happened? Thanks J Leonard -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL
I'm just learning MySQL and PHP so this fresh from my last snoop through the documentation, hope it will help. From the command line you can make a global query like - SELECT * FROM pets; and all the info stored in the table will be shown. To update a record use the update query: UPDATE pet SET birth = 1998-04-15 WHERE name = Kitty; This changes only one record at a time. I hope this will also work from a shell account on a web hosting service it should.. As mentioned earlier phpMyAdmin is very nice and makes life a lot more fun G... BUT not all hosting services have phpMyAdmin installed so ya gotta do it the hard way.. On Monday 04 February 2002 09:34 am, you wrote: Go download PHPMyAdmin. - Original Message - From: Morten Nielsen [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, February 04, 2002 8:34 AM Subject: [PHP-DB] MySQL Hi, Is there an easy way to see the data in a table? I made a table that contains information about people. How do I see/change the contenst of the table? Thanks, Morten -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Ken Thompson, North West Antique Autos Payette, Idaho Email: [EMAIL PROTECTED] http://www.nwaa.com Sales and brokering of antique autos and parts. Linux- Coming Soon To A Desktop Near You Registered Linux User #183936 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL connect
On Monday 04 February 2002 10:54 am, you wrote: Hi all, Ok I am learning this on my own but I could use some help. I have started these two pages test.php and config.php here is the code: test.php ? // include the database configuration include config.php; In looking at my include page I noticed there were parenthisis around the include statement, maybe this is your problem. include(header.inc); // connect to database mysql_connect($db[host],$db[user],$db[password],$db[database]) or die (sorry not successful); // if no connect then exit exit; // if connect successful echo (you have connected); ? config.php ? // database config $db[host] = localhost; $db[user] = me; $db[password] = mypassword; $db[database] = mydb; ? All I'm trying to do is successfully connect to the database but it returns sorry not successful. What have I done wrong? I have gone straight from the php pocket reference manual and it doesn't work. Would someone please explain what has happened? Thanks J Leonard -- Ken Thompson, North West Antique Autos Payette, Idaho Email: [EMAIL PROTECTED] http://www.nwaa.com Sales and brokering of antique autos and parts. Linux- Coming Soon To A Desktop Near You Registered Linux User #183936 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Combined sql statement
This just showed up, where was it stuck? Essentially you do a SELECT into your target table, if the target key exists, which you determine from row count, then you do an UPDATE, otherwise an INSERT. I don't know what else you have wrapped around this, in terms of control structure, so here's the guts: // determine whether or not a record exists // you will have to tell us what the WHERE condition is $strCondition = db_field_name = 'some_value' ; $sql = select * from $table_name where $strCondition; $result = mysql_query( $sql ); if( mysql_num_rows( $result ) 0 ) { // a record was returned, thus an UPDATE, using the same where condition $sql = UPDATE $table_name SET our_serv='$our_serv' where $str_condition; } else { // no record was returned, so an INSERT $sql = INSERT INTO $table_name SET our_serv='$our_serv'; } $result = mysql_query( $sql ); //and here you can test for the affected rows to determine success or failure. This is sort of a hybrid, in that the table name is stored in a variable, whereas the field name isn't. One would assume that there is some variation of field names among table so this will need some cleaning up. There should also be some testing as to whether or not the $result is valid. If this has already been answered, well I guess I shouldn't reply to stale posts. Shame on me! Regards - Miles At 10:07 PM 1/29/2002 -0700, jas wrote: I would like to know how to have a php script loop through two different sql statements and use one according to a yes or no answer. I am still kinda new to php and I already have my sql statements, but I dont know how to use php to tell it to use one of the other. My sql statements are as follows... $sql = INSERT INTO $table_name (our_serv) VALUES (\$our_serv\) ; $sql = UPDATE $table_name SET our_serv=\$our_serv\; How can I get it to pick one of these... for instance if there is no entry in the unique table to enter one using the first sql statement, or if there is already an entry to simply update and overwrite the current table entry. Any help would be appriciated and if you could please document it so I understand and dont have to ask again. Thanks, jas WOW, your neat -- 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 connect
on 2/4/02 12:54 PM, J Leonard at [EMAIL PROTECTED] appended the following bits to my mbox: mysql_connect($db[host],$db[user],$db[password],$db[database]) or The above function call only has three parameters. The database isn't specified in the connect call but selected later. Try: mysql_connect($db[host],$db[user],$db[password]); mysql_select_db($db[database]) Paul ?php while ($self != asleep) { $sheep_count++; } ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL connect
mysql_connect() function only takes 3 arguments (servername, username, pass) . Select your database by using mysql_select_db() function... Try to rewrite the code as: mysql_connect($db[host],$db[user],$db[password]); mysql_select_db($db[database]); Refer to: http://www.php.net/manual/en/ref.mysql.php Gurhan -Original Message- From: J Leonard [mailto:[EMAIL PROTECTED]] Sent: Monday, February 04, 2002 12:54 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] MySQL connect Hi all, Ok I am learning this on my own but I could use some help. I have started these two pages test.php and config.php here is the code: test.php ? // include the database configuration include config.php; // connect to database mysql_connect($db[host],$db[user],$db[password],$db[database]) or die (sorry not successful); // if no connect then exit exit; // if connect successful echo (you have connected); ? config.php ? // database config $db[host] = localhost; $db[user] = me; $db[password] = mypassword; $db[database] = mydb; ? All I'm trying to do is successfully connect to the database but it returns sorry not successful. What have I done wrong? I have gone straight from the php pocket reference manual and it doesn't work. Would someone please explain what has happened? Thanks J Leonard -- 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] Subject: Re: FIle Uploading to database
RE Could not execute f query : Is it possibly a typo, such that INSERT INTO Canidate should read Candidate (ie with the correct number of d's for the english speling ;-) Just a thought. Neil. At 02:13 04/02/2002 +, Todd Williamsen [EMAIL PROTECTED] wrote: $query = INSERT INTO Canidate(FirstName, LastName, Industry, Address1, Address2, City, State, Zip, LocationPref, Phone, Email, ResumeUp) VALUES ('$FirstName', '$LastName', '$Industry' '$Address1', 'Address2', '$City', '$State', '$Zip', '$LocationPref', '$Phone', '$Email', '$ResumeUp2'); $result = @mysql_query($query, $connection) or die(could not execute query); -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: LEFT JOIN in UPDATE
[EMAIL PROTECTED] (Adv. Systems Design) writes: I was simply going by the docs themselves: http://www.mysql.com/doc/A/N/ANSI_diff_Sub-selects.html (see bottom of page) yes, using REPLACE may be a solution. But you have to make a copy of the original table, because REPLACE cannot access the values of the old row directly. I'd prefer to do this in the mysql way - on the php side. Now before you get your flamethrower out...yes I AM KIDDING...I realize that mysql is maturing and all these features will EVENTUALLY make it in... Some compromises are necessary when using mysql, but often the advantages prevailing. Lutz -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: FIle Uploading to database
GOOD What was the problem!?!? Dan On Monday, February 4, 2002, at 01:44 PM, [EMAIL PROTECTED] wrote: Ok, I got it woohoo!!! It works! Thanks for all your help -Original Message- From: Dan Brunner [mailto:[EMAIL PROTECTED]] Sent: Monday, February 04, 2002 10:35 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Re: FIle Uploading to database Does the file come from a Form?? Your hosting provider...might be the problem. Dan On Monday, February 4, 2002, at 09:57 AM, [EMAIL PROTECTED] wrote: I changed it to its absolute path... It resides with my hosting provider... I removed the $pat = array(#, @, *, , %, @,$,',`); $w= '_'; $pic_name2 = str_replace ($pat, $w, stripslashes($pic_name)); To see if the file is being uploaded... Here is the actual code: $db = @mysql_select_db(williamsen, $connection) or die(Could not select database); $sql =INSERT INTO Canidate (id, FirstName, LastName, Industry, Address1, Address2, City, State, Zip, LocationPref, Phone, Email, ResumeUp) VALUES (\$id\, \$FirstName\, \$LastName\, \$Industry\, \$Address1\, \$Address2\, \$City\, \$State\, \$Zip\, \$LocationPref\, \$Phone\, \$Email\, \$userfile\ ); $result = @mysql_query($sql,$connection) or die(OOPS!! Couldn't Execute Query!); exec(cp '$userfile', 'home/sites/site190/web/resumes/$userfile'); The $sql query needed the $connection in there for it to work -Original Message- From: Dan Brunner [mailto:[EMAIL PROTECTED]] Sent: Monday, February 04, 2002 9:46 AM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Re: FIle Uploading to database Make sure the path name is correct Let's say you compiled apache with this prefix /web you must have the full path name to work...like this exec(cp '$ResumeUp' '/web/htdocs/resumes/$ResumeUp2'); Also check permissions... I think that was my problem at first too!!! You can also do debug the script. Like this echo $ResumeUp; That should print the tmp file you form created... Let me know... Once this pasts...It works really well... Dan On Monday, February 4, 2002, at 09:35 AM, [EMAIL PROTECTED] wrote: The INSERT statement works fine now, but the file isn't being uploaded. I cannot figure out why -Original Message- From: Dan Brunner [mailto:[EMAIL PROTECTED]] Sent: Monday, February 04, 2002 7:54 AM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Re: FIle Uploading to database Hey did you get it to work yet?!?! Dan On Sunday, February 3, 2002, at 09:08 PM, [EMAIL PROTECTED] wrote: Umm.. SET parameter is for the UPDATE query Adam Royle [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... You missed the SET parameter in your query... example is below... $query = INSERT INTO Canidate SET (FirstName, LastName, Indus... Adam -Original Message- From: Todd Williamsen [mailto:[EMAIL PROTECTED]] Sent: Monday, February 04, 2002 11:06 AM To: [EMAIL PROTECTED] Subject: Re: FIle Uploading to database Well... thanks to Dan Burner for the script... BUT I cannot get this friggin INSERT statement to execute.. which craps out.. I cannot figure it out. I have been staring at it for about an hour and I still cannot figure it out here it is: $db = @mysql_select_db($db_name, $connection) or die(Could not select database); $query = INSERT INTO Canidate(FirstName, LastName, Industry, Address1, Address2, City, State, Zip, LocationPref, Phone, Email, ResumeUp) VALUES ('$FirstName', '$LastName', '$Industry' '$Address1', 'Address2', '$City', '$State', '$Zip', '$LocationPref', '$Phone', '$Email', '$ResumeUp2'); $result = @mysql_query($query, $connection) or die(could not execute query); $pat = array(#, @, *, , %, @,$,',`); $w= '_'; $ResumeUp2 = str_replace ($pat, $w, stripslashes($ResumeUp)); exec(cp '$ResumeUp' '/resumes/$ResumeUp2'); ? it errors out on the $result could not execute query Let me know if you need more info! Thank you! -- 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] Update
Hi, I am having problems with this code. I want to update a members number of days they have been a member can anyone help? $query[days]=(UPDATE users set days_member VALUES = ('days_member' + '1')); $result=mysql_query($query[days]); Thanks in advance JD -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Update
Hello, I am not sure why you want to do this. Wouldn't it be better to use calculate the days from the date signed up, rather than through updating your database every day. Try using datediff. Jeremy At 01:51 PM 2/4/2002 -0800, Jennifer Downey wrote: Hi, I am having problems with this code. I want to update a members number of days they have been a member can anyone help? $query[days]=(UPDATE users set days_member VALUES = ('days_member' + '1')); $result=mysql_query($query[days]); Thanks in advance JD -- 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
Try it without quotes around days_member and 1. Gurhan -Original Message- From: Jennifer Downey [mailto:[EMAIL PROTECTED]] Sent: Monday, February 04, 2002 4:51 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Update Hi, I am having problems with this code. I want to update a members number of days they have been a member can anyone help? $query[days]=(UPDATE users set days_member VALUES = ('days_member' + '1')); $result=mysql_query($query[days]); Thanks in advance JD -- 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
Hi Jennifer, I am having problems with this code. I want to update a members number of days they have been a member can anyone help? $query[days]=(UPDATE users set days_member VALUES = ('days_member' + '1')); $result=mysql_query($query[days]); =1 RTFM 6.4.5 UPDATE Syntax =2 Why would you want to take on a daily load like this. Wouldn't it be easier to record joining date and calculate membership period when needed? =dn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Update
Yeah I didn't notice that.. VALUES must not be there . it should be : set days_member=days_member+1 thanks for pointing that out:) Gurhan -Original Message- From: Lokesh Verma [mailto:[EMAIL PROTECTED]] Sent: Monday, February 04, 2002 5:12 PM To: Gurhan Ozen Subject: Re: [PHP-DB] Update i don't know why that 'VALUES' is there? Lokesh - Original Message - From: Gurhan Ozen [EMAIL PROTECTED] To: Jennifer Downey [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, February 05, 2002 3:28 AM Subject: RE: [PHP-DB] Update Try it without quotes around days_member and 1. Gurhan -Original Message- From: Jennifer Downey [mailto:[EMAIL PROTECTED]] Sent: Monday, February 04, 2002 4:51 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Update Hi, I am having problems with this code. I want to update a members number of days they have been a member can anyone help? $query[days]=(UPDATE users set days_member VALUES = ('days_member' + '1')); $result=mysql_query($query[days]); Thanks in advance JD -- 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
Why? There's absolutely no point -- record the date a person became a member and calculate the number of days from that. In addition, what happens when you fail to run the update routine? Or someone runs it twice? Or it half runs, then dies because the database has gotten so large that the script times out? Who is going to keep track of when it was run? What check value scheme will you have in place to make certain none of this happens? What you are planning to do is bad practice. Please reconsider. Regards - Miles Thompson At 01:51 PM 2/4/2002 -0800, Jennifer Downey wrote: Hi, I am having problems with this code. I want to update a members number of days they have been a member can anyone help? $query[days]=(UPDATE users set days_member VALUES = ('days_member' + '1')); $result=mysql_query($query[days]); Thanks in advance JD -- 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
Why? Because I am learning. It seemed like the way to do it. I didn't know all those things could happen. There is NO documentation, manual or tutorial for that matter that gives clear, in English directions on how to do something. People just assume that everyone knows techie talk. So they explain in technical terms in which 98% of us don't understand. So we have to do things by trial and error and learn by our mistakes and pray that someone who does know can explain in a way that we can understand. Regards Jennifer Downey Miles Thompson [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Why? There's absolutely no point -- record the date a person became a member and calculate the number of days from that. In addition, what happens when you fail to run the update routine? Or someone runs it twice? Or it half runs, then dies because the database has gotten so large that the script times out? Who is going to keep track of when it was run? What check value scheme will you have in place to make certain none of this happens? What you are planning to do is bad practice. Please reconsider. Regards - Miles Thompson At 01:51 PM 2/4/2002 -0800, Jennifer Downey wrote: Hi, I am having problems with this code. I want to update a members number of days they have been a member can anyone help? $query[days]=(UPDATE users set days_member VALUES = ('days_member' + '1')); $result=mysql_query($query[days]); Thanks in advance JD -- 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] Dealing with One-to-Many SELECTS (MySQL)
Hello, I have three tables: CREATE TABLE event ( eid int(10) unsigned NOT NULL auto_increment, tid smallint(5) unsigned NOT NULL default '0', itimestamp int(10) unsigned NOT NULL default '0', etimestamp int(10) unsigned NOT NULL default '0', somethingelse tinyint(4) NOT NULL default '0', PRIMARY KEY (eid) ); CREATE TABLE line ( eid int(10) unsigned NOT NULL default '0', position tinyint(3) unsigned NOT NULL auto_increment, did int(11) NOT NULL default '0', PRIMARY KEY (eid,position) ); CREATE TABLE data ( did int(10) unsigned NOT NULL auto_increment, data varchar(255) binary NOT NULL default '0', PRIMARY KEY (did), UNIQUE KEY data (data) ); Basically I insert data into event and record the resulting eid from the auto increment. Then I insert my raw data into the data table, recording each did from the auto increment. Lastly, I insert multiple records into the line table, one for each of my raw data elements. I then am able to do: SELECT event.eid,event.tid,event.itimestamp,event.etimestamp,data.did,data.data FROM event LEFT JOIN line ON event.eid=line.eid LEFT JOIN data ON line.did=data.did WHERE event.eid='45' to get a single event. This all works fine, however this is the result set I get back: 45 48 1012359206 1012134660 1 Jan 45 48 1012359206 1012134660 2 27 45 48 1012359206 1012134660 61 07 45 48 1012359206 1012134660 39 31 45 48 1012359206 1012134660 5 00 45 48 1012359206 1012134660 6 ahost 45 48 1012359206 1012134660 69 14823 45 48 1012359206 1012134660 10 my.host.com My question is there any way to consolidate the rows, so that I avoid the redundant data? In other words: 45 48 1012359206 1012134660 1 Jan 2 27 61 07 39 31 5 00 6 ahost 69 14823 10 my.host.com I could do this in multiple queries, which works fine when there is only one event returned, but if I query on a different field (event.tid for example, which is a type of line) things get very messy. Currently I am handling this consolidation in PHP, but it's CPU and memory intensive and it just seems a waste to have so much of the same data returned. If anyone could give me some pointers on doing this, or, let me know if I'm missing something obvious or that there is a better way to possibly design my schema. Please feel free to ask me anything for clarification etc. Thank you Hans -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Update
Jennifer, I appreciate and I'm glad that you're learning. What you were proposing is an easy trap to fall into. It's just that I've worked on systems where, for no apparent reason, the designer had decided to store the number of days/months someone had been a member / tenant / on-account customer, what have you. Or decided to store the number of days an invoice was overdue. There's an old adage, that the best way to learn how to build boats is to repair them. Well, maybe how not to build boats. That's what working on those systems taught me, plus my own measure of mistakes. With regard to techie talk, have you looked at any of the tutorials on the web on how to work with PHP, and if you're not a programmer, some basic stuff on determining what you want from your program, what you need to get that result, and outlining the necessary processing steps. Once you start working with PHP, or any other scripting language, you're crossing over into programming land. Time spent with pencil and paper, figuring out these things, is amply repaid when you sit down to the keyboard. Don't be disconcerted by the programming part of it. The web is a strange place, very unlike any other programming environment, with conditions which trip up people who have been programming for years. Regards - Miles Thompson PS When updating a numerical field in MySQL, the general form of the statement is like this update table_name set counter = counter + 1 where some_condition_is_met some_condition_is_met being something like where member_id = '$member_id', or where daily_temp = $temp_today /mt PPS You on the West Coast? At 05:24 PM 2/4/2002 -0800, Jennifer Downey wrote: Why? Because I am learning. It seemed like the way to do it. I didn't know all those things could happen. There is NO documentation, manual or tutorial for that matter that gives clear, in English directions on how to do something. People just assume that everyone knows techie talk. So they explain in technical terms in which 98% of us don't understand. So we have to do things by trial and error and learn by our mistakes and pray that someone who does know can explain in a way that we can understand. Regards Jennifer Downey Miles Thompson [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Why? There's absolutely no point -- record the date a person became a member and calculate the number of days from that. In addition, what happens when you fail to run the update routine? Or someone runs it twice? Or it half runs, then dies because the database has gotten so large that the script times out? Who is going to keep track of when it was run? What check value scheme will you have in place to make certain none of this happens? What you are planning to do is bad practice. Please reconsider. Regards - Miles Thompson At 01:51 PM 2/4/2002 -0800, Jennifer Downey wrote: Hi, I am having problems with this code. I want to update a members number of days they have been a member can anyone help? $query[days]=(UPDATE users set days_member VALUES = ('days_member' + '1')); $result=mysql_query($query[days]); Thanks in advance JD -- 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
[PHP-DB] RE: Combined sql statement
Miles is correct, this the standard way (without knowing your application and if I could figure out another trick). But if you absolutely don't want to use two SQL blocks you can set your SQL block to something like this: $sql = DELETE FROM $table_name WHERE our_serv = \$our_serv\ INSERT INTO $table_name (our_serv) VALUES (\$our_serv\); This works because if the value in question is not there the DELETE statement is perfectly valid - but it won't delete anything. What you're looking for is an INSERT OR UPDATE statement and there is no such thing in SQL (no doubt there ought to be one - but there isn't). As for using a DELETE and then an INSERT statement - that's just about as much work for the DBMS as an UPDATE. Good Luck, Frank On 2/4/02 6:30 PM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: From: Miles Thompson [EMAIL PROTECTED] Date: Mon, 04 Feb 2002 14:20:29 -0400 To: jas [EMAIL PROTECTED],[EMAIL PROTECTED] Subject: Re: [PHP-DB] Combined sql statement This just showed up, where was it stuck? Essentially you do a SELECT into your target table, if the target key exists, which you determine from row count, then you do an UPDATE, otherwise an INSERT. I don't know what else you have wrapped around this, in terms of control structure, so here's the guts: // determine whether or not a record exists // you will have to tell us what the WHERE condition is $strCondition = db_field_name = 'some_value' ; $sql = select * from $table_name where $strCondition; $result = mysql_query( $sql ); if( mysql_num_rows( $result ) 0 ) { // a record was returned, thus an UPDATE, using the same where condition $sql = UPDATE $table_name SET our_serv='$our_serv' where $str_condition; } else { // no record was returned, so an INSERT $sql = INSERT INTO $table_name SET our_serv='$our_serv'; } $result = mysql_query( $sql ); //and here you can test for the affected rows to determine success or failure. This is sort of a hybrid, in that the table name is stored in a variable, whereas the field name isn't. One would assume that there is some variation of field names among table so this will need some cleaning up. There should also be some testing as to whether or not the $result is valid. If this has already been answered, well I guess I shouldn't reply to stale posts. Shame on me! Regards - Miles At 10:07 PM 1/29/2002 -0700, jas wrote: I would like to know how to have a php script loop through two different sql statements and use one according to a yes or no answer. I am still kinda new to php and I already have my sql statements, but I dont know how to use php to tell it to use one of the other. My sql statements are as follows... $sql = INSERT INTO $table_name (our_serv) VALUES (\$our_serv\) ; $sql = UPDATE $table_name SET our_serv=\$our_serv\; How can I get it to pick one of these... for instance if there is no entry in the unique table to enter one using the first sql statement, or if there is already an entry to simply update and overwrite the current table entry. Any help would be appriciated and if you could please document it so I understand and dont have to ask again. Thanks, jas WOW, your neat -- 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] Re: php-db Digest 5 Feb 2002 02:30:20 -0000 Issue 1034
Hans, On 2/4/02 6:30 PM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: From: hz11 [EMAIL PROTECTED] Date: Mon, 04 Feb 2002 21:17:15 -0500 To: [EMAIL PROTECTED] Subject: Dealing with One-to-Many SELECTS (MySQL) to get a single event. This all works fine, however this is the result set I get back: 45 48 1012359206 1012134660 1 Jan 45 48 1012359206 1012134660 2 27 45 48 1012359206 1012134660 61 07 45 48 1012359206 1012134660 39 31 45 48 1012359206 1012134660 5 00 45 48 1012359206 1012134660 6 ahost 45 48 1012359206 1012134660 69 14823 45 48 1012359206 1012134660 10 my.host.com My question is there any way to consolidate the rows, so that I avoid the redundant data? According to the DBMS there is no redundant data in the above results set. Yes we see the first 4 columns are identical but because the last two are not the same the set contains no duplicate rows (commands like DISTINCT and GROUOP BY will not do what you wish). In other words: 45 48 1012359206 1012134660 1 Jan 2 27 61 07 39 31 5 00 6 ahost 69 14823 10 my.host.com This cannot be done with a single select statement - SQL results are very square (think excel spread sheet) every row will have every column and you cannot have a single row / column with distinct values from multiple rows. Even if you're talking about aggregate functions (average, count, min, max) these aren't distinct values. I could do this in multiple queries, That's the way I'd do it. which works fine when there is only one event returned, but if I query on a different field (event.tid for example, which is a type of line) things get very messy. Try opening two DB connections - you've got one working already $res1 has the result of SELECT event.eid, event.tid, event.itimestamp, event.etimestamp FROM event WHERE event.eid='45' (I've left out the join and date table) /* I'll assume ODBC but it works for any type */ While(odbc_fetch_row($res1)) { $eid = odbc_result($res1,1); /* Print or whatever you want to do with*/ /* event.eid, event.tid, event.itimestamp, event.etimestam */ $sql2 = SELECT data.did,data.data FROM event LEFT JOIN line ON event.eid=line.eid LEFT JOIN data ON line.did=data.did WHERE event.eid=/$my_eid/; $res2 = odbc_exec($con2,$sql2); While(odbc_fetch_row($res2)) { /* now fetch and do what you want with the date.did and data */ $did = odbc_result($res2,1); $data = odbc_result($res2,2); } } Not so messy, No? Good Luck, Frank -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] odbc functions
Does anyone have experience of using odbc_primarykeys??? I'm writing a script to let me port a database from Access to MySQL without having to write all the table definitions by hand. But I can't get odbc_primarykeys to work - it comes back with: Warning: SQL error: , SQL state 0 in SQLPrimaryKeys I don't really know what the modifier and owner parameters should do, and suspect thats where the problem lies. I tried them as , % and . Running PHP 4.0.4 on NT 4.0 Workstation, with Access 97 Richy. == Richard Black Systems Programmer, DataVisibility Ltd - http://www.datavisibility.com Tel: 0141 435 3504 Email: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] odbc functions
Richard, Simple example using MS SQL Server: ?php $dsn=Northwind; $usr=sa; $pwd=; $qual=Northwind; $owner=dbo; $table=Orders; $conn_id = odbc_connect($dsn, $usr, $pwd) or die (odbc_error()); $result_id = odbc_primarykeys($conn_id, $qual, $owner, $table) or die (odbc_error()); odbc_result_all($result_id); ? Best regards, Andrew Hill Director of Technology Evangelism OpenLink Software http://www.openlinksw.com Universal Data Access Data Integration Technology Providers -Original Message- From: Richard Black [mailto:[EMAIL PROTECTED]] Sent: Monday, February 04, 2002 10:36 AM To: '[EMAIL PROTECTED]' Cc: '[EMAIL PROTECTED]'; '[EMAIL PROTECTED]' Subject: [PHP-DB] odbc functions Does anyone have experience of using odbc_primarykeys??? I'm writing a script to let me port a database from Access to MySQL without having to write all the table definitions by hand. But I can't get odbc_primarykeys to work - it comes back with: Warning: SQL error: , SQL state 0 in SQLPrimaryKeys I don't really know what the modifier and owner parameters should do, and suspect thats where the problem lies. I tried them as , % and . Running PHP 4.0.4 on NT 4.0 Workstation, with Access 97 Richy. == Richard Black Systems Programmer, DataVisibility Ltd - http://www.datavisibility.com Tel: 0141 435 3504 Email: [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-DB] Re: Oracle connection
The oracle extension is not installed. This is why PHP doesn't recognize ora_logon(). So you have to install PHP with oracle extension. BTW, you would prefer installing oci8 extension instead of oracle. oci8 is the newest extension to connect to an oracle 7 or 8 database (see ocilogon() and friends). Regards, Philippe Paulo Cesar [EMAIL PROTECTED] a écrit dans le message news: 003201c1ad7c$4fe14d80$[EMAIL PROTECTED] I'm trying to connect to a Oracle database but i'm receiving the following error message in the browser: Fatal error: Call to undefined function: ora_logon() in /home/httpd/html/restrito/testes/teste_bd.php on line 17 I'm starting to learn PHP now, so I don't know what does it means or what I need to do to make it work -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php