php-windows Digest 1 Aug 2001 00:57:41 -0000 Issue 678 Topics (messages 8590 through 8603): Re: extracting value from array 8590 by: elias win2000pro and PHP inst.? 8591 by: Niclas 8593 by: Phil Driscoll 8594 by: Leon Re: DB Date check !! 8592 by: Mike Flynn Help with a query, and return result on the same page. 8595 by: Martin Tengowski 8597 by: Mike Flynn submitting records from multiple DB tables 8596 by: Andrew.Martin 8598 by: Hugh Bothwell Variable scope in loops 8599 by: Tom Tsongas 8600 by: Paul Smith 8601 by: Paul Smith Works through DOS, not through Apache 8602 by: SHAWN mail(); error 8603 by: Chris Burwell Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] ----------------------------------------------------------------------
nice one! "Hugh Bothwell" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > <[EMAIL PROTECTED]> wrote in message > > 011401c11958$26d38f60$[EMAIL PROTECTED]">news:011401c11958$26d38f60$[EMAIL PROTECTED]... > > > let's say there is an array with 10 elements. > > One of elements has value 'xyz123' - I do not know which one. > > How can I extract this element from the array and > > have a new array with all other element, except extracted one. > > // original array > $arr = array("a", "b", "c", "d", "xyz123", "f", "g"); > // list of values to remove > $remove = array("xyz123"); > > // do it > $result = array_diff($arr, $remove); > > // show results > foreach($result as $val) > echo "<br>$val"; > > >
Well, I maby the first (or not) who is installing PHP on my computer, I cant get it to work . The isnt. runs fine and I get no errors. but when I am trying to access my PHP-based pages I dont get any output, only a loggin-window though I am logged in as "Administrator"??? And when I logg in with password and domain I still cant get anything on my page.... Please help me!!! Niclas Meyer
On Tuesday 31 July 2001 14:21, Niclas wrote: > Well, I maby the first (or not) who is installing PHP on my computer, I > cant get it to work . > The isnt. runs fine and I get no errors. but when I am trying to access my > PHP-based pages I dont get any output, only a > loggin-window though I am logged in as "Administrator"??? > > And when I logg in with password and domain I still cant get anything on my > page.... > > Please help me!!! The anonymous user of IIS is usually IUSR_<machinename>. If your php files don't have read access for IUSR_<machinename> (and the 'check file exists' box was ticked in your script mapping) then IIS will want to authenticate the user. If plain text authentication is enabled and microsoft's own authentication is disabled, then IIS will send authentication headers to the browser and cause the username/password dialog box to appear. Assuming this is what is wrong, all you need to do is give read access to IUSR_<machinename> for all your php files (and indeed any other files which you want the user to be able to access). Cheers -- Phil Driscoll
Hi there give more info!!! This could be an ISAPI module issue or IIS With IIS Anonymous user access needs to be granted. With ISAPI you need to setup a general filter under home dir in web properties with '%s %s' after the %drive%/%folder%/php.exe Cheers Niclas wrote: > Well, I maby the first (or not) who is installing PHP on my computer, I cant > get it to work . > The isnt. runs fine and I get no errors. but when I am trying to access my > PHP-based pages I dont get any output, only a > loggin-window though I am logged in as "Administrator"??? > > And when I logg in with password and domain I still cant get anything on my > page.... > > Please help me!!! > > Niclas Meyer > > -- > PHP Windows 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]
date('Y-m-d') is how MySQL likes to see DateTime types represented. $today = date('Y-m-d'); $query = 'SELECT * FROM tblEvents '; $query .= "WHERE dtmEventDate >= $today "; $query .= 'ORDER BY dtmEventDate DESC'; $result = mysql_query($query); ...etc... Hope that helps. -Mike At 10:26 AM 7/31/2001 +0200, you wrote: >Hi, > >I want to check the date of numerous records in many DB tables, I have tried >using the >date (Ymd); function but it doesn't appear to work, not sure whats going >wrong. > >I set a variable based on this function and use this variable within the >select statement! >Anyone know whats happening or if there is a descent solution available? > >thanks, > >Andrew -=- Mike Flynn - Burlington, VT -=- [EMAIL PROTECTED] http://www.mikeflynn.net/ * Give blood * American schoolchildren today are taking four times as many psychiatric meds as all of the rest of the world combined.
I am trying to query a database, and return the results on the same page. I have a form to enter the item that I want to query. I would like to have a table below, so that the results would be displayed. right now I'm just using a small database to get the things working. I can query a database and display the data when the page is loading, but not able to do a query and display only the desired data from a form. Most of the database work that I would need to do right now is on this order. Have a page setup where the users would come in and select or enter the query criteria, and the data will then be pulled and displayed from the database. I am connected to MySql, and can connect to ODBC... I have been going through tutorials and also using DreamWeaver UltraDev with PHP extensions...but have not found an example like this... Thanks Martin
Hi Martin, PHP is only executed when the user requests the page. It is all processed by the server on the server-side (thus it's called a server-side scripting language), before returning any HTML to the user. Thus, you can't "dynamically" pull data once a page has loaded. What you can do is simulate it by either posting the user's selections through a form or passing the user's selections via a query string, back to the same page, and then have the newly generated PHP reflect the change. The one exception is to use JavaScript to simulate dynamic database querying, by pre-loading all data into JavaScript variables (most likely arrays), and then use the client-side JavaScript to pull it up when the user interacts with the page. But this isn't good for large sets of data and relies on the user having JavaScript enabled and a browser that handles it well. So, getting back to the original solution, you could do something where on the initial page the user picks the stuff just like you've said, then submits it, then the same page comes up with the selected info as well as the database results. Do you see what I'm saying? I know I say it kind of complicated, but it's actually a pretty basic thing. You'll get the hang of it. -Mike At 10:48 AM 7/31/2001 -0400, Martin Tengowski wrote: >I am trying to query a database, and return the results on the same >page. > >I have a form to enter the item that I want to query. > >I would like to have a table below, so that the results would be >displayed. >right now I'm just using a small database to get the things working. I >can query a database and display the data when the page is loading, but >not able to do a query and display only the desired data from a form. > >Most of the database work that I would need to do right now is on this >order. >Have a page setup where the users would come in and select or enter the >query criteria, >and the data will then be pulled and displayed from the database. > >I am connected to MySql, and can connect to ODBC... >I have been going through tutorials and also using DreamWeaver UltraDev >with PHP extensions...but have not found an example like this... > >Thanks > >Martin > > > >-- >PHP Windows 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] -=- Mike Flynn - Burlington, VT -=- [EMAIL PROTECTED] http://www.mikeflynn.net/ * Give blood * American schoolchildren today are taking four times as many psychiatric meds as all of the rest of the world combined.
I have a list of records displayed in a table generated from a DB (records are from numerous DB tables). The table consits of check box(name = DB name and index), title(url link with ID) date and status When the check box is selected I need to retrieve the DB table name and a specific ID The selected records are then to be updated in the DB, but my problems arise when trying to get the correct DB table name and ID. I would ideally like to loop through the list get the DB table name and ID and then submit. But I not sure how to do this. I have tried filling hidden form fields when I submit, these in turn are used to insert data to the DB individualy (I can do this with Javascript but then have problems calling the PHP function to update the DB!) Is there an easier solution? I can't see anything on PhP net, or am I looking in the wrong place? Thanks.
"Andrew.Martin" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I have a list of records displayed in a table generated from a DB > (records are from numerous DB tables). The table consits of check > box(name = DB name and index), title(url link with ID) date > and status Could you give a sample - the HTML code for one table row, with descriptive dummy values? > When the check box is selected I need to retrieve the DB > table name and a specific ID. The selected records are > then to be updated in the DB, but my problems arise > when trying to get the correct DB table name and ID. I see two ways of doing this; you can either return a parseable string from each checkbox, or you can return several associative arrays. Method #1: ========= in form file: <input type='checkbox' name='checkbox[]' value='$tablename;$id' > in recipient: <?php foreach ($checkbox as $val) { $res = explode(";", $val, 2); // table name = $res[0] // id = $res[1] } ?> Method #2 ======== in form file: <input type='checkbox' name='tbl[$num]' value='$tablename' > <input type='hidden' name='id[$num]' value='$id' > in recipient: <?php foreach($tbl as $key => $val) { // table name = $val // id = $id[$key] } ?> NOTE: both of these are quite insecure, letting any meddler specify whichever table id and row they want to play with, or maybe even execute arbitrary code of their own, depending on exactly how this is implemented; I strongly suggest using an associative array to filter the table names and forcing the id to an integer value. If you really want to be safe, you could generate a random key for each row of each table, pass it through a hidden field, and check it against the value again before changing the row. That way, whackers can only change rows that they have seen the 'password' for, which they would have the right to change anyway.
Hi folks. I have an interesting problem with regards to variable scope in loops. Now I understand how this operates in functions but its the first time I have seen variable scope in a loop. Below is a code snippet of what I have: // execute SQL query OCIExecute($sql_statement) or die("Couldn't execute statement."); // get number of columns for use later $num_columns = OCINumCols($sql_statement); // format results by row while (OCIFetch($sql_statement)) { for ($i = 1; $i < $num_columns+1; $i++) { // Create array to store fetch results $incident_array[i] = OCIResult($sql_statement,$i); //echo "<P>Incident array value $i: $incident_array[i]</P>"; } } // Output results of incident array echo "<P>First array value: $incident_array[1]</P>"; Now I 'expected' the echo statement to properly display the results of the first array element but instead, the value is blank. Now when I uncomment the echo statement WITHIN the for loop, it does display so I know the values are being stored but apparantly the scope of the array is within the loop and not outside. How can I make the array values accessible outside of the loop? I found a 'global' statement in the documentation but it didn't seem to like taking an array as a parameter. I had it looking something like this: global $incident_array[]; Any help would be appreciated. Tom Tsongas
Well, first of all, to get the first value of the array you should call it as $incidnet_array[0]. Now doing that *might* fix your problem if you were only recieving one value for the array. So if you were getting output inside the array, how many outputs were you getting? One or two or more? ~Paul Tom Tsongas wrote: > > Hi folks. > > I have an interesting problem with regards to variable scope in loops. > Now I understand how this operates in functions but its the first time I > have seen variable scope in a loop. > > Below is a code snippet of what I have: > > // execute SQL query > OCIExecute($sql_statement) or die("Couldn't execute statement."); > > // get number of columns for use later > $num_columns = OCINumCols($sql_statement); > > // format results by row > while (OCIFetch($sql_statement)) { > for ($i = 1; $i < $num_columns+1; $i++) { > // Create array to store fetch results > $incident_array[i] = OCIResult($sql_statement,$i); > //echo "<P>Incident array value $i: $incident_array[i]</P>"; > > } > } > // Output results of incident array > echo "<P>First array value: $incident_array[1]</P>"; > > Now I 'expected' the echo statement to properly display the results of > the first array element but instead, the value is blank. Now when I > uncomment the echo statement WITHIN the for loop, it does display so I > know the values are being stored but apparantly the scope of the array > is within the loop and not outside. > > How can I make the array values accessible outside of the loop? I found > a 'global' statement in the documentation but it didn't seem to like > taking an array as a parameter. I had it looking something like this: > > global $incident_array[]; > > Any help would be appreciated. > > Tom Tsongas > > -- > PHP Windows 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] -- Paul Smith [EMAIL PROTECTED] http://www.dostuff.net
Whoops, my mistake. I read your code completely wrong. Ignore my comments. You are calling the first variable but I didn't expect it to be called like that. I expected that the array would be appended to by calling it like this: $incident_array[]=$value; Nevermind, sorry 'bout that. Paul Smith wrote: > > Well, first of all, to get the first value of the array you should call > it as $incidnet_array[0]. Now doing that *might* fix your problem if you > were only recieving one value for the array. So if you were getting > output inside the array, how many outputs were you getting? One or two > or more? > > ~Paul > > Tom Tsongas wrote: > > > > Hi folks. > > > > I have an interesting problem with regards to variable scope in loops. > > Now I understand how this operates in functions but its the first time I > > have seen variable scope in a loop. > > > > Below is a code snippet of what I have: > > > > // execute SQL query > > OCIExecute($sql_statement) or die("Couldn't execute statement."); > > > > // get number of columns for use later > > $num_columns = OCINumCols($sql_statement); > > > > // format results by row > > while (OCIFetch($sql_statement)) { > > for ($i = 1; $i < $num_columns+1; $i++) { > > // Create array to store fetch results > > $incident_array[i] = OCIResult($sql_statement,$i); > > //echo "<P>Incident array value $i: $incident_array[i]</P>"; > > > > } > > } > > // Output results of incident array > > echo "<P>First array value: $incident_array[1]</P>"; > > > > Now I 'expected' the echo statement to properly display the results of > > the first array element but instead, the value is blank. Now when I > > uncomment the echo statement WITHIN the for loop, it does display so I > > know the values are being stored but apparantly the scope of the array > > is within the loop and not outside. > > > > How can I make the array values accessible outside of the loop? I found > > a 'global' statement in the documentation but it didn't seem to like > > taking an array as a parameter. I had it looking something like this: > > > > global $incident_array[]; > > > > Any help would be appreciated. > > > > Tom Tsongas > > > > -- > > PHP Windows 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] > > -- > Paul Smith > [EMAIL PROTECTED] > http://www.dostuff.net > > -- > PHP Windows 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] -- Paul Smith [EMAIL PROTECTED] http://www.dostuff.net
Can anyone tell me why the following code won't work when I call it through Apache, but it DOES work when I do it in a Command Prompt? It gives me 0 when I run it through Apache. I'm have PHP set up to run as CGI. PHP 4.0.6 w/ latest 4.0.7-dev snapshot on top. What I'm going to end up doing is copying the files from an UNC path over to the local server (running PHP), but I can't get anything to work with UNC paths when called through Apache, not even a system call to "move". But everything always works in a Command Prompt. If you can think of another way I could do this on demand, I would greatly appreciate it, as this is driving me crazy! <? if ($dir = @opendir("//workstation//test")) { while($file = readdir($dir)) { if ($file !="." && $file !="..") $arFiles[] = $file; } } ?> File_Array Count: <? $asize = sizeof($arFiles); print $asize; ?> Thanks, Shawn Sellars
when i try to send an e-mail using the mail(); function i get the following message: Warning: Failed to Connect in d:\Server\apache\htdocs\dev\inc\functions.inc on line 26 Line 26 of the functions.inc file reads like this: $mailsend = mail("$email", "$subject", "$body", "From: $from\r\nContent-type:text/plain"); Can someone help me out?