Re: [PHP-DB] Upgrading from php -4.0.3
on 2/27/02 2:51 AM, Marco Coletta at [EMAIL PROTECTED] appended the following bits to my mbox: I would like to upgrade to newer version of php, ho can supply detailed instructions. You can start here: http://www.php.net/manual/en/installation.php And if you have difficulty, post your problems to the PHP-INSTALL list. Since this is the database list, you *should not* post those questions here. Paul ?php while ($self != asleep) { $sheep_count++; } ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: php-db Finding records with NULL values
That may work for a single field in a record that is NULL, but I'm trying to join two tables, and report the lines that do not have an entry in the second thus: Question Table Q_idQuestion 1Question 1 2Question 2 3Question 3 4Question 4 Response Table R_idMember_idQ_idResponse 111Yes 213No So, member 1 has answered questions 1 and 3 - I want to find how to get the q_ids of the remaining questions... Q_id 2 4 Something like: SELECT q.q_id FROM questions q, responses r WHERE q.q_id=r.q_id AND r.member_id='1' AND r.id=NULL% NB This doesn't work... :( Or maybe it's better by taking the questions they have done, SELECT q_id FROM responses where member='1' and somehow subtracting this from the complete list, SELECT q_id FROM questions Any clues? Robin Frank Flynn [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Pretty easy really SELECT * FROM foo WHERE bar is NULL - DON'T use quotes NULL is a valid string it is not the same as NULL - Some DBMS's allow you to say bar = NULL but technically this is wrong because NULL is undefined and cannot be equal to anything not even another NULL. - Also is not NULL - be sure you blank fields are NULL and not - A clever way to search for both and NULL in the same query is: SELECT * FROM foo WHERE NOT bar This may not work in all DBMS's but give it a try; OR would work too. Good Luck, Frank On 2/26/02 2:20 PM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: From: Robin McKenzie [EMAIL PROTECTED] Date: Tue, 26 Feb 2002 21:49:00 - To: [EMAIL PROTECTED] Subject: Finding records with NULL values I have a table of questions, and a table of responses (initially empty) which gets updated every time an answer is submitted, with the question number, member id and response. I wish to produce a SELECT query that will find the questions that haven't been answered by a particular member, i.e. a query that finds the questions that DO NOT have an entry in responses. How can I do this? Regards, Robin -- Frank Flynn Poet, Artist Mystic -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: php-db Finding records with NULL values
Robin That may work for a single field in a record that is NULL, but I'm trying to join two tables, and report the lines that do not have an entry in the second thus: Question Table Q_idQuestion 1Question 1 2Question 2 3Question 3 4Question 4 Response Table R_idMember_idQ_idResponse 111Yes 213No So, member 1 has answered questions 1 and 3 - I want to find how to get the q_ids of the remaining questions... Q_id 2 4 Check out OUTER JOINs (RTFM: 6.4.1.1 JOIN Syntax) =dn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] forced page links...
I am wondering if there is a good tutorial on how to use php to make users come from a page before they can access another. For instance, say you have one page called index.php which contains a form that once filled in links to a confirmation page to verify the users data was entered correctly then from there links to a page that stores the users data into a database table. The problem I would like to alleviate is to make sure the users cannot just type in the name of the last page in the url and put a blank entry into the database. I have read a few tutorials on using sessions but I am unclear on how the use of sessions would require the user to visit each page in succession. Thanks in advance, Jas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: forced page links...
Hi there :) I use session variables to do this, once the user has logged in and you know they are who they say they are, set a session variable using session_register(isloggedin); $isloggedin = yes; And at the top of every page you want protected simply do a check to see if it is set or not. Below code checks to see if that var is set and if not it redirects them to another page. ?php session_start(); ? ?php if (!isset($HTTP_SESSION_VARS[islogged])){ header(Location:index.php); } ? Hope this helps, Joe :) Jas [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I am wondering if there is a good tutorial on how to use php to make users come from a page before they can access another. For instance, say you have one page called index.php which contains a form that once filled in links to a confirmation page to verify the users data was entered correctly then from there links to a page that stores the users data into a database table. The problem I would like to alleviate is to make sure the users cannot just type in the name of the last page in the url and put a blank entry into the database. I have read a few tutorials on using sessions but I am unclear on how the use of sessions would require the user to visit each page in succession. Thanks in advance, Jas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Advantage Database Server
Hi there :) I believe you can connect to an Advantage Db through unified odbc functions. Check the manual at www.php.net Cheers, Joe :) Stewart Gateley [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Has anybody had any luck or tried connecting to ADS from PHP? What is required? Thanks, Stewart __ Do You Yahoo!? Yahoo! Greetings - Send FREE e-cards for every occasion! http://greetings.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Advantage Database Server
Hello- We are currently developing a PHP client for the Advantage Database Server and expect to have it released in approx. 2 weeks. As mentioned in the previous post, it will access ADS through a unified ODBC method. Please contact me directly for additional information or if you are interested in taking a peek at the beta. Thanks, Chuck Vertrees Extended Systems, Inc Advantage Database Sales 800-235-7576 x5030 Lerp wrote in message [EMAIL PROTECTED]... Hi there :) I believe you can connect to an Advantage Db through unified odbc functions. Check the manual at www.php.net Cheers, Joe :) Stewart Gateley [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Has anybody had any luck or tried connecting to ADS from PHP? What is required? Thanks, Stewart __ Do You Yahoo!? Yahoo! Greetings - Send FREE e-cards for every occasion! http://greetings.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: forced page links...
Can you accomplish this without having the user logged in? I am unconcerned with whether or not the user has logged in, I simply need the user to not be able to bypass a page with a form to go directly to the end page which will connect and store the form contents into a db. Thanks in advance, Jas Lerp [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi there :) I use session variables to do this, once the user has logged in and you know they are who they say they are, set a session variable using session_register(isloggedin); $isloggedin = yes; And at the top of every page you want protected simply do a check to see if it is set or not. Below code checks to see if that var is set and if not it redirects them to another page. ?php session_start(); ? ?php if (!isset($HTTP_SESSION_VARS[islogged])){ header(Location:index.php); } ? Hope this helps, Joe :) Jas [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I am wondering if there is a good tutorial on how to use php to make users come from a page before they can access another. For instance, say you have one page called index.php which contains a form that once filled in links to a confirmation page to verify the users data was entered correctly then from there links to a page that stores the users data into a database table. The problem I would like to alleviate is to make sure the users cannot just type in the name of the last page in the url and put a blank entry into the database. I have read a few tutorials on using sessions but I am unclear on how the use of sessions would require the user to visit each page in succession. Thanks in advance, Jas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: forced page links...
Hello!! What I would do is have both the 2 page and the last page on the the same page!! All my pages are only two...a form page and a processing page...that's it However You could also have a variable pass from page to page, like a hidden variable, either in a form, or with cookies. And check for that variable every page with an If...else..statement. like If (empty($CheckPLEASE){ echo Sorry You are out of order; exit(); }else{ echo hey your good to go!!; } And so on and so on... Dan On Wednesday, February 27, 2002, at 02:03 AM, [EMAIL PROTECTED] wrote: Can you accomplish this without having the user logged in? I am unconcerned with whether or not the user has logged in, I simply need the user to not be able to bypass a page with a form to go directly to the end page which will connect and store the form contents into a db. Thanks in advance, Jas Lerp [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi there :) I use session variables to do this, once the user has logged in and you know they are who they say they are, set a session variable using session_register(isloggedin); $isloggedin = yes; And at the top of every page you want protected simply do a check to see if it is set or not. Below code checks to see if that var is set and if not it redirects them to another page. ?php session_start(); ? ?php if (!isset($HTTP_SESSION_VARS[islogged])){ header(Location:index.php); } ? Hope this helps, Joe :) Jas [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I am wondering if there is a good tutorial on how to use php to make users come from a page before they can access another. For instance, say you have one page called index.php which contains a form that once filled in links to a confirmation page to verify the users data was entered correctly then from there links to a page that stores the users data into a database table. The problem I would like to alleviate is to make sure the users cannot just type in the name of the last page in the url and put a blank entry into the database. I have read a few tutorials on using sessions but I am unclear on how the use of sessions would require the user to visit each page in succession. Thanks in advance, Jas -- 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: forced page links...
hi jas, am sure you asked this before and i already replied. Anyway miles posted this which is more elaborated than the one i proposed: *** This is at the top of every file requiring an authenticated user on one of our sites: ? include(secure.php)? and secure.php consists of this, all on one line, with no cr or lf at the end. ? session_start();session_register( origin );$origin=$PHP_SELF; $HTTP_SERVER_VARS[ PHP_AUTH_USER ] !=winkum TP_SERVER_VARS[ PHP_AUTH_PW ] !=blinkum ) { if( !session_is_registered( member_id ) ) { header(Location: user_logon.php\n); } }? The user_logon.php script handles all details of processing the user: reading their cookie and authenticating, prompting for username/password, authenticating setting cookie. If authentication succeeds member_id is registered and created as a session var (it contains no info, merely exists) and the user is returned to the originating page, or by default, to index.php. The $HTTP_SERVER_VARS with the hard-coded passwords are there so that htdig can be authenticated to index these pages. Regards - Miles Thompson - Original Message - From: jas [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, February 27, 2002 12:03 AM Subject: [PHP-DB] Re: forced page links... Can you accomplish this without having the user logged in? I am unconcerned with whether or not the user has logged in, I simply need the user to not be able to bypass a page with a form to go directly to the end page which will connect and store the form contents into a db. Thanks in advance, Jas Lerp [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi there :) I use session variables to do this, once the user has logged in and you know they are who they say they are, set a session variable using session_register(isloggedin); $isloggedin = yes; And at the top of every page you want protected simply do a check to see if it is set or not. Below code checks to see if that var is set and if not it redirects them to another page. ?php session_start(); ? ?php if (!isset($HTTP_SESSION_VARS[islogged])){ header(Location:index.php); } ? Hope this helps, Joe :) Jas [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I am wondering if there is a good tutorial on how to use php to make users come from a page before they can access another. For instance, say you have one page called index.php which contains a form that once filled in links to a confirmation page to verify the users data was entered correctly then from there links to a page that stores the users data into a database table. The problem I would like to alleviate is to make sure the users cannot just type in the name of the last page in the url and put a blank entry into the database. I have read a few tutorials on using sessions but I am unclear on how the use of sessions would require the user to visit each page in succession. Thanks in advance, Jas -- 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] Sorting the result
Hi, I've come across a problem and I'm affraid that I'm lacking the skills of writing proper SQL queries in order to solve this. I'm building a little search engine for my site (yes, from scratch! It doesn't have to be the best, but I think that for my personal use it will be enough) and the bit of code I have right now is as follows: snip /* I'm using MySQL 3.23.37 together with 4.0.6 on a FreeBSD box */ $article_query = mysql_query(select article_name, article_text from articles where article_name LIKE '%$q%') or die (mysql_error()); /* where $q is the search query with a space added in front */ while ($results = mysql_fetch_array($article_query)) { $art_name = $results[article_name]; $article_text = $results[article_text]; $q_count = substr_count($article_text, $q); echo b$art_name/bp$article_textp; } /snap But what I'd like to achieve is that the results would be displayed in a way ORDER BY $q_count DESC - the entry with most $q_count would be displayed first, next one second etc. I'm sure that there is a way to sort the array with PHP, but is it also possible to let the MySQL do the job? It would save some CPU power I think... if not, what would be the easiest way to do it with PHP? TIA, Kristjan P.S. Please CC me as well, I am only on the digest. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Re: forced page links...
Jas, Try looking into the $HTTP_REFERER variable, for example; ? if ($HTTP_REFERER != PageItShouldBeComingFrom.php) { Header (Location: index.php); } // blah blah ? Cheers -Original Message- From: jas [mailto:[EMAIL PROTECTED]] Sent: Wednesday, 27 February 2002 6:04 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Re: forced page links... Can you accomplish this without having the user logged in? I am unconcerned with whether or not the user has logged in, I simply need the user to not be able to bypass a page with a form to go directly to the end page which will connect and store the form contents into a db. Thanks in advance, Jas Lerp [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi there :) I use session variables to do this, once the user has logged in and you know they are who they say they are, set a session variable using session_register(isloggedin); $isloggedin = yes; And at the top of every page you want protected simply do a check to see if it is set or not. Below code checks to see if that var is set and if not it redirects them to another page. ?php session_start(); ? ?php if (!isset($HTTP_SESSION_VARS[islogged])){ header(Location:index.php); } ? Hope this helps, Joe :) Jas [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I am wondering if there is a good tutorial on how to use php to make users come from a page before they can access another. For instance, say you have one page called index.php which contains a form that once filled in links to a confirmation page to verify the users data was entered correctly then from there links to a page that stores the users data into a database table. The problem I would like to alleviate is to make sure the users cannot just type in the name of the last page in the url and put a blank entry into the database. I have read a few tutorials on using sessions but I am unclear on how the use of sessions would require the user to visit each page in succession. Thanks in advance, Jas -- 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] Sorting the result
$article_query = mysql_query(select article_name, article_text from articles where article_name LIKE '%$q%' ORDER BY $q_count DESC ) or die (mysql_error()); Put the ORDER BY $q_count DESC in your SQL statement and that will make MySQL do the sorting for you. PHP will get it already sorted. Is that what you wanted? -w -- William Fong - [EMAIL PROTECTED] Phone: 626.968.6424 x210 | Fax: 626.968.6877 Wireless #: 805.490.7732| Wireless E-mail: [EMAIL PROTECTED] - Original Message - From: Kristjan Kanarik [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, February 27, 2002 2:51 PM Subject: [PHP-DB] Sorting the result : Hi, : : I've come across a problem and I'm affraid that I'm lacking the skills of : writing proper SQL queries in order to solve this. I'm building a little : search engine for my site (yes, from scratch! It doesn't have to be the : best, but I think that for my personal use it will be enough) and the bit : of code I have right now is as follows: : : snip : /* I'm using MySQL 3.23.37 together with 4.0.6 on a FreeBSD box */ : : $article_query = mysql_query(select article_name, article_text from articles where article_name LIKE '%$q%') or die (mysql_error()); : /* where $q is the search query with a space added in front */ : : while ($results = mysql_fetch_array($article_query)) { : $art_name = $results[article_name]; : $article_text = $results[article_text]; : $q_count = substr_count($article_text, $q); : echo b$art_name/bp$article_textp; : } : : /snap : : But what I'd like to achieve is that the results would be displayed in a : way ORDER BY $q_count DESC - the entry with most $q_count would be : displayed first, next one second etc. I'm sure that there is a way to sort : the array with PHP, but is it also possible to let the MySQL do the job? : It would save some CPU power I think... if not, what would be the easiest : way to do it with PHP? : : TIA, : Kristjan : : P.S. Please CC me as well, I am only on the digest. : : : -- : 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] pg_pconnect Causing SegFaults?!?!
Greetings everyone, I've been having a very frustrating problem over the past few months that I've ***finally*** tracked down the cause of Any questions/comments/thoughts/ideas you can provide would be *greatly* appreciated. Symptoms: - IE, Opera, Lynx all report page cannot be displayed and/or server error about half the time - NS has no problems at all. - Apache error.log shows child (PID) seg faulted. Problem post analysis: - The Apache processes can accept and successfully serve one connection from a client. The next connection results in the Apache child process seg faulting, the error getting logged in error.log, nothing gets reported in access.log, and the Apache parent process respawns a new child. - The newly spawned child will accept and serve one connection from a client before also segfaulting. I've eliminated every possibility I could think of while troubleshooting this. i.e. it's not SSL, it's not PHP itself, it's not Apache itself. It's the pg_pconnect() function. Throughout my troubleshooting, I came upon it by accident, really, that I discovered all my problems went away when I replaced the pg_pconnect() function with the (almost deprecated according to the docs) pg_connect() function. In troubleshooting this, I created a shell script that continuously loads various pages from the site (using Lynx -dump -mime_header url), counts the iterations, and bails as soon as a page fails to load. Running this against plain HTML files, PHP scripts (i.e. that simply echo something or provide phpinfo(), etc.), over SSL or not all work just fine. (15,000 loads in each case without fault.) As soon as I try accessing a PHP script that includes the pg_pconnect() function, it dies almost immediately. If I stop/start Apache right before trying this, I'll get X successful loads (where X = Apache's 'StartServers' property). After that, I'll get a continuous mixture of successful and failed loads from then on So, let me repeat here As soon as I switched from pg_pconnect() to pg_connect(), everything worked perfectly after that. (i.e. 15000 loads without an error.) More info: - My platform is up-to-date Debian GNU/Linux (sid) (Apache 1.3.23, PHP 4.1.1, PostgreSQL 7.1.3, etc.) - As above, this is *not* browser specific. (Found a *lot* of google hits with people having problems with IE and SSL and seg faults, etc. Completely unrelated.) - Note from above, though, that NS is unaffected by this problem. It *never* has a problem. My assumption is that NS will simply silently retry (several times) if the connection fails for some reason, until it does get a valid response from the server (Kudos!!! ;-) So, any thoughts? Comments? Suggestions? Have I found a bug in pg_pconnect()? How can I provide more info to track this down further? Best regards, Kevin Traas Chief Information Officer, Co-founder Merilus, Inc. ---=== www.merilus.com ===--- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] why won't session_start() work?
when I do: session_start(); session_register('signor'); session_register('username'); I get: Warning: Cannot send session cookie - headers already sent by (output started at /var/www/html/index.php:3) in /var/www/html/index.php on line 14 Warning: Cannot send session cache limiter - headers already sent (output started at /var/www/html/index.php:3) in /var/www/html/index.php on line 14 Anybody know why? Thanks. Ry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] why won't session_start() work?
Ryan, you need to make all of those calls *before* ANY output has been sent by your script, otherwise you can't send a header any more. so the TOP of a script might look like ?php session_start(); $signor = $monsieur + $madame; session_register(signor); // the rest of your code goes here ? html ?php // more PHP ? if you get what I mean. you can actually do a lot of coding before you start the session if you want, provided you haven't done any echo() print() or anything that sends information as output. HTH beau // -Original Message- // From: Ryan Snow [mailto:[EMAIL PROTECTED]] // Sent: Thursday, 28 February 2002 9:06 AM // To: [EMAIL PROTECTED] // Subject: [PHP-DB] why won't session_start() work? // // // // when I do: // session_start(); // session_register('signor'); // session_register('username'); // // // I get: // // Warning: Cannot send session cookie - headers already sent // by (output // started at /var/www/html/index.php:3) in // /var/www/html/index.php on line 14 // // Warning: Cannot send session cache limiter - headers already // sent (output // started at /var/www/html/index.php:3) in // /var/www/html/index.php on line 14 // // Anybody know why? // // Thanks. // // Ry // // -- // 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] accessing system cmds w/ PHP
Can anyone tell me how to access linux system commands using php. Tried the system() cmd but no luck. Does it require a wrapper to work?Thanks, JJ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] accessing system cmds w/ PHP
Have a look at trying backticks. http://www.php.net/manual/en/language.operators.execution.php [TK] -Original Message- From: Jeremiah Jester [mailto:[EMAIL PROTECTED]] Sent: Thursday, 28 February 2002 12:37 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] accessing system cmds w/ PHP Can anyone tell me how to access linux system commands using php. Tried the system() cmd but no luck. Does it require a wrapper to work?Thanks, JJ -- 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] accessing system cmds w/ PHP
JJ, I seem to recall most people saying that the shorthand works best $output = `chmod -R 777 *'; HTH beau // -Original Message- // From: Jeremiah Jester [mailto:[EMAIL PROTECTED]] // Sent: Thursday, 28 February 2002 9:37 AM // To: [EMAIL PROTECTED] // Subject: [PHP-DB] accessing system cmds w/ PHP // // // Can anyone tell me how to access linux system commands using // php. Tried the // system() cmd but no luck. Does it require a wrapper to work?Thanks, // JJ // // // -- // 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] Question about advanced SQL
Hi. I need some guidance for writing an effective query (instead of processing through PHP). I lets says I have two tables, tblCDs and tblOrders. tblCD cdID| cdTitle | cdArtist -- 1 | Great Hits | Bon Jovi 2 | Forever Young| The Youngsters 3 | Now and Then | Beach Boys 4 | Cheesy Name | Two Tones tblOrders orderID | cdID_FK | ordererID -- 1 | 1| 442 2 | 3| 233 3 | 1| 233 Now, I want to select all the records from tblCD where the cdID does not appear in any row of tblOrders.cdID_FK This means that it selects all the CDs that have not been ordered. The results of the query should be cdID| cdTitle | cdArtist -- 2 | Forever Young| The Youngsters 4 | Cheesy Name | Two Tones I know how I can do this in PHP (two queries - put all cdID_FK in an array, and on displaying the other query, check if it is in the array, and display if not) but there HAS to be an easier way. Adam. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Question about advanced SQL
SELECT tblCD.cdID, tblCD.cdTitle, tblCD.cdArtist FROM tblCD, tblOrders WHERE tblOrders.cdID = tblCD.cdID AND tblCD.cdID NOT IN ( SELECT cdID FROM tblOrders ) The support for this sort of nested query will very between RDBMSs but the statement above is most generic. Databases like postgres will not only support this but they will also have proprietary ways of achiveing the same thing more efficiently. Some databases also support LEFT JOIN, OUTER JOIN directives but support and implementation will vary. I havn't tested the above query but it should work :-) Although it probably isn't the most efficient. [TK] -Original Message- From: Adam Royle [mailto:[EMAIL PROTECTED]] Sent: Thursday, 28 February 2002 1:38 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Question about advanced SQL Hi. I need some guidance for writing an effective query (instead of processing through PHP). I lets says I have two tables, tblCDs and tblOrders. tblCD cdID | cdTitle | cdArtist -- 1 | Great Hits | Bon Jovi 2 | Forever Young| The Youngsters 3 | Now and Then | Beach Boys 4 | Cheesy Name | Two Tones tblOrders orderID | cdID_FK | ordererID -- 1 | 1| 442 2 | 3| 233 3 | 1| 233 Now, I want to select all the records from tblCD where the cdID does not appear in any row of tblOrders.cdID_FK This means that it selects all the CDs that have not been ordered. The results of the query should be cdID | cdTitle | cdArtist -- 2 | Forever Young| The Youngsters 4 | Cheesy Name | Two Tones I know how I can do this in PHP (two queries - put all cdID_FK in an array, and on displaying the other query, check if it is in the array, and display if not) but there HAS to be an easier way. Adam. -- 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] accessing system cmds w/ PHP
Hello... Try exec() I know it works moving files. Dan -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 27, 2002 7:37 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] accessing system cmds w/ PHP Can anyone tell me how to access linux system commands using php. Tried the system() cmd but no luck. Does it require a wrapper to work?Thanks, JJ -- 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] Question about advanced SQL
select * from tblCd where cdId not in (select distinct cdId from tblOrders); On Thu, Feb 28, 2002 at 12:37:49PM +1000, Adam Royle wrote: Hi. I need some guidance for writing an effective query (instead of processing through PHP). I lets says I have two tables, tblCDs and tblOrders. tblCD cdID | cdTitle | cdArtist -- 1 | Great Hits | Bon Jovi 2 | Forever Young| The Youngsters 3 | Now and Then | Beach Boys 4 | Cheesy Name | Two Tones tblOrders orderID | cdID_FK | ordererID -- 1 | 1| 442 2 | 3| 233 3 | 1| 233 Now, I want to select all the records from tblCD where the cdID does not appear in any row of tblOrders.cdID_FK This means that it selects all the CDs that have not been ordered. The results of the query should be cdID | cdTitle | cdArtist -- 2 | Forever Young| The Youngsters 4 | Cheesy Name | Two Tones I know how I can do this in PHP (two queries - put all cdID_FK in an array, and on displaying the other query, check if it is in the array, and display if not) but there HAS to be an easier way. Adam. -- 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] Storing image path to database
Hi, Woud someone be able to help? I can't for the life of me figure out how to get this to store a image path instead of the image itself. In other words I want to make this so that the user isn't uploading an image. I want to use a radio or check box that they pick from. Any help would be appreciated. ?php if ($submit) { $data = addslashes(fread(fopen($form_data, r), filesize($form_data))); $uid={$session[uid]}; $result=MYSQL_QUERY(INSERT INTO binary_data (uid,description,bin_data,filename,filesize,filetype) . VALUES ('$uid','$form_description','$data','$form_data_name','$form_data_size','$fo rm_data_type')); $id= mysql_insert_id(); print pbYour pet has been entered/b; MYSQL_CLOSE(); } else { ? form method=post action=?php echo $PHP_SELF; ? enctype=multipart/form-data File Description:br input type=text name=form_description size=40 INPUT TYPE=hidden name=MAX_FILE_SIZE value=100 brFile to upload/store in database:br input type=file name=form_data size=40 I already have the image on the server how do I change this to store the path pinput type=submit name=submit value=submit /form a href=store.phpback/a ?php } ? this is the table CREATE TABLE binary_data ( id int(4) NOT NULL auto_increment, uid int(10) NOT NULL default '0', description varchar(50) default NULL, bin_data longblob, filename varchar(50) default NULL, filesize varchar(50) default NULL, filetype varchar(50) default NULL, PRIMARY KEY (id) ) TYPE=MyISAM; Thanks in advance Jennifer Downey -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Question about advanced SQL
Hi, I assumed that you was used MySQL for database. With MySQL you can used this SQL to find different row select tblcd.* from tblcd left join tblorder on tblcd.cdid=tblorder.cdid where tblorder.cdid is null sommai At 12:37 28/2/2002 +1000, Adam Royle wrote: Hi. I need some guidance for writing an effective query (instead of processing through PHP). I lets says I have two tables, tblCDs and tblOrders. tblCD cdID| cdTitle | cdArtist -- 1 | Great Hits | Bon Jovi 2 | Forever Young| The Youngsters 3 | Now and Then | Beach Boys 4 | Cheesy Name | Two Tones tblOrders orderID | cdID_FK | ordererID -- 1 | 1| 442 2 | 3| 233 3 | 1| 233 Now, I want to select all the records from tblCD where the cdID does not appear in any row of tblOrders.cdID_FK This means that it selects all the CDs that have not been ordered. The results of the query should be cdID| cdTitle | cdArtist -- 2 | Forever Young| The Youngsters 4 | Cheesy Name | Two Tones I know how I can do this in PHP (two queries - put all cdID_FK in an array, and on displaying the other query, check if it is in the array, and display if not) but there HAS to be an easier way. Adam. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Please be informed that all e-mail which are addressing to thaithanakit.co.th will need to be changed to BTsecurities.com by March 1, 2002 Thank you. :-) -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Object Base Database Access
Hi folks, i'm currently developing an module which provides an object based access to databases content (does not mean that i use OOP) for example we have defined an class descriptor for person, which specifies, that an person-record consists of the fields ID (which is the OID, fetched from sequence person_seq), mtime (which is also the mtime field and so touched when updating the record), firstname, lastname, ... then we can fetch the whole person record i.e. with: $person = obj_find ( person, array ( ID = 12 ) ); $person now contains an array with the person record in the form array ( OID = 12, mtime = 2002-02-28 07:23:00, firstname = douglas, lastname = adams ) you can also update whole objects (or some single fields) of the record or query multiple ones ... well, i'm not really good in explaining the stuff, so please ask me if you've got some questions. ~-n -- Enrico Weigelt== meTUX IT services software development, IT service, internet security solutions www: http://www.metux.de/phone: +49 36207 519931 email: [EMAIL PROTECTED]cellphone: +49 174 7066481 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Force Refresh on Another Window w/ Javascript
I have a question, let's say i have my main page (so called) called indexphp I have also displayed a buttonin indexphp, which i will used the onClick event to trigger a windowopen function to the same main page, indexphp (but with parameters) input type=button value=Add New Records onClick=parentlocationhref='% echo $PHP_SELF; %?action=addnew'; so my indexphp should have these codes % if( $action == addnew ) { } else { } % NOTE: i'm using asp tags set in phpini during the adding of new records, i have also display another button called Close Window And when I close this, how do i force the main page (which is in a different window to refresh, to display the newly added records) This is because after I have closed the add new records window, and close it, i would have to have either a refresh button or you would have to refresh it yourself And thanks in advance regards -- PHP Database Mailing List (http://wwwphpnet/) To unsubscribe, visit: http://wwwphpnet/unsubphp
Re: [PHP-DB] Force Refresh on Another Window w/ Javascript
Sorry about the priority, guess it was set unintentionally, out of habit from my working place, I think. Beau Lebens wrote: please don't use the important (X-Priority header) on your message - we're all important here :) anyway, your question - it's actually JavaScript that you want, and you need something like this on the body of the HTML page in the window you open body onClose=javascript:opener.document.refresh(); something like that will do it for you, take a look at the javascript developer's guide (from developer.netscape.com) HTH beau // -Original Message- // From: Shahmat Dahlan [mailto:[EMAIL PROTECTED]] // Sent: Thursday, 28 February 2002 2:36 PM // To: PHP-DB // Subject: [PHP-DB] Force Refresh on Another Window w/ Javascript // Importance: High // // // I have a question, let's say i have my main page (so called) called // index.php. // // I have also displayed a buttonin index.php, which i will used the // onClick event to trigger a window.open function to the same main // page, index.php (but with parameters). // // input type=button value=Add New Records // onClick=parent.location.href='% echo $PHP_SELF; // %?action=addnew'; // // so my index.php should have these codes // // % // ... // ... // if( $action == addnew ) // { // // ... // } // else { // // } // % // // NOTE: i'm using asp tags set in php.ini // // during the adding of new records, i have also display another button // called Close Window. And when I close this, how do i force the main // page (which is in a different window to refresh, to display the newly // added records). This is because after I have closed the add // new records // window, and close it, i would have to have either a refresh button or // you would have to refresh it yourself. // // And thanks in advance. // // regards // // // -- // 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] errorr log
Hello guys, anyone can help me with this kind of error log tail -f /www/log/error_log [ cut ] PHP Warning: Failed to write session data (files) Please verify that the current setting of sessionsave_path is correct (/tmp) in Unknown on line 0 PHP Warning: Failed to write session data (files) Please verify that the current setting of sessionsave_path is correct (/tmp) in Unknown on line 0 PHP Warning: Failed to write session data (files) Please verify that the current setting of sessionsave_path is correct (/tmp) in Unknown on line 0 PHP Warning: Failed to write session data (files) Please verify that the current setting of sessionsave_path is correct (/tmp) in Unknown on line 0 PHP Warning: Failed to write session data (files) Please verify that the current setting of sessionsave_path is correct (/tmp) in Unknown on line 0 in every php script that i have , i didn't set any variable about sessionsave_path I just set in my phpini , and the past is coreect /tmp But why in apache error log i got warning for session data (files) anyone experience with this problem too ? wIEn -- -== HonesT Is The BesT PoLicY ==- - -- PHP Database Mailing List (http://wwwphpnet/) To unsubscribe, visit: http://wwwphpnet/unsubphp
[PHP-DB] Question about setting up multiple relations
Hi, I have an Image table in a MySQL database that will be used to store the location of all images used on my site Some images will relate to an Article table (articleid) and some images may relate to a Member table (memberid) As it's possible that there may be an articleid that is the same as a memberid, I am considering adding two fields to the Image table (article_id and member_id) one of which will be left blank for each record, depending on the image's relation For example, if mypicjpg is related to articleid 288 in the Article table, then I would insert 288 into the article_id field in the Image table but leave the member_id field blank Is this kosher, or is there a better way to do this? Thanks! -- PHP Database Mailing List (http://wwwphpnet/) To unsubscribe, visit: http://wwwphpnet/unsubphp
Re: [PHP-DB] errorr log
check if YOU can write/read on tmp. Erwien Samantha Y a écrit : Hello guys, anyone can help me with this kind of error log tail -f /www/log/error_log [ cut ] PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 in every php script that i have , i didn't set any variable about session.save_path. I just set in my php.ini , and the past is coreect /tmp. But why in apache error log i got warning for session data (files). anyone experience with this problem too ? wIEn -- -== HonesT Is The BesT PoLicY ==- - -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Marius Ursache (3563 || 3494) \|/ \|/ '/ ,. \` /_| \__/ |_\ \__U_/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] errorr log
the permision in /tmp it's OK , because my session it's work already in /tmp , but the i stil got an error message bellow. wIEn [EMAIL PROTECTED] wrote: check if YOU can write/read on tmp. Erwien Samantha Y a écrit : Hello guys, anyone can help me with this kind of error log tail -f /www/log/error_log [ cut ] PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 in every php script that i have , i didn't set any variable about session.save_path. I just set in my php.ini , and the past is coreect /tmp. But why in apache error log i got warning for session data (files). anyone experience with this problem too ? wIEn -- -== HonesT Is The BesT PoLicY ==- - -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Marius Ursache (3563 || 3494) \|/ \|/ @'/ ,. \`@ /_| \__/ |_\ \__U_/ -- -== HonesT Is The BesT PoLicY ==- - -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php