[PHP] sessions and email
All, I am using sessions for my application to verify a user has logged in: // Verify the user is logged in. if (!isset($_SESSION['basic_is_logged_in']) || $_SESSION['basic_is_logged_in'] !== true) { // If not logged in, redirect to the login page. header('Location: login.php'); exit; } If anyone tries to go to any page in the application via the address bar, they are correctly redirected to the login page. However, if someone that is currently logged into the application using I.E. goes to File - Send - Page by Email, the person they email the link to can open it and use the application without logging in and the address bar uses a local path like: C:\Documents and Settings\my_name\Local Settings\Temporary Internet Files\OLK18\My Page (2).htm How can I prevent the emailed pages from being able to access the application if it is a local path or the user hasn't logged in?
[PHP] NULLS vs Empty result in PHP
Morning! Just a quick question. Say I have a column in my database that could contain NULLS, empty spaces, or an actual value. If I do: $my_query = SELECT my_column FROM my_database WHERE 1 = 1; $my_result = ifx_query($my_query, $connect_id); while($row = ifx_fetch_row($my_result)) { $my_column = trim($row['my_column']); if ($my_column != ) { echo Test; } } The way PHP assigns the query results to the $my_column variable, wouldn't; if ($my_column != ) not do anything for the rows that contained NULLS or empty spaces?
Re: [PHP] Re: NULLS vs Empty result in PHP
using empty() is ´the right way to check a var for NULL or however, it also depends what MySQL has got as setuo definition for empty fields. on textfields u can define an epmty string as default. So say these are the first three results of my query: some text //The column actually has data //The column contains a series of spaces NULL //The column contains a NULL value As long as I trim() the result, if (!empty()) would skip any results where the column containsOR NULL, correct?
Re: [PHP] Date +30 comparison
I'm really struggling with dates in PHP. (Yes, I tried reading the manual)... Can someone provide code that does this: Takes current date, assigns it to a variable (let's say $today) Then adds 30 days to $today variable Takes a string ($nexteval) like '8/26/2009' and compare it to $today. The variable $nexteval must be greater than $today (which is today + 30 days) or a message is echoed. I'm finding this difficult to do, but I'm coming from an ASP background. Any help appreciated. David, Look up date() and mktime() in the manual. To get today's date is easy: date('m/d/Y'); But when wanting to add days/months/years to a date, you need to use mktime() mktime() breaks apart a date into hours/minutes/seconds/months/days/years. Therefore I always break up my date into these types fo sections. $month = date('m'); $day = date('d'); $year = date('Y'); Now that I have them seperated I create a variable $future_date and assign it the value I want. In your case, 30 days in the future. $future_date = mktime(0,0,0,date($month),date($day)+30,date($year)); Now I put it back into a date format. $future_date = date('m/d/Y',$future_date); echo $future_date; Today is September 1st and the value of $future_date is October 1st because there are 30 days in Spetember. Now you can compare your dates. if ($nexteval $future_date) { echo This date has already passed; } else { *do some processing* } Hope that helps. Dan
[PHP] File Open Prompt?
Greetings, I'm having a problem trying to get a file download prompt. Basically I have a page with image links. When the link is clicked, the user is directed to another page I have. That page finds the image path based on the image ID from the previous page. Once the image path is found I copy the image to the local webserver and rename the proprietary extension, .0D9 to .tif Once the file is renamed to .tif I want the download prompt to come up. You know, where it says, Open Save Cancel. I've tried using: $fp = fopen($new_file,r) ; header(Content-Type: image/tif); while (! feof($fp)) { $buff = fread($fp,filesize($new_file)); print $buff; } But that just gives me heiroglyphics on the screen instead of prompting the user to download. Here is my code that copies and renames the file: if ($page != || $page != ) { exec(xcopy .$page. .$topage.); } $orig_file = $topage.\\.$objectid..0D9; //echo $orig_file; $new_file = $topage.\\.$objectid..tif; //echo $new_file; rename($orig_file,$new_file); Any ideas on how to make the browser give the download prompt for $new_file? Thanks, Dan
Re: [PHP] File Open Prompt?
You will need to add some headers to the page to popup the prompt, at least with these. $filename = 'somefile.tif'; $filesize = filesize($filename); header('Content-Type: application/force-download'); header('Content-disposition: attachement; filename=' . $filename); header('Content-length: ' . $filesize); Eric I don't know what I'm doing wrong. I've tried: header('Content-Description: File Transfer'); header('Content-Type: application/force-download'); header('Content-Length: ' . filesize($filename)); header('Content-Disposition: attachment; filename=' . basename($file)); readfile($file); AND if (file_exists($new_file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($new_file )); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($new_file)); ob_clean(); flush(); readfile($new_file); exit; } But everything I do just sends heiroglyphics to the screen instead of giving the download box.
Re: [PHP] Freeing Memory
How does that work considering that mysql_query() only returns true or false on INSERT? I'd expect the script to fail on $result not being a valid resource. I don't know about mysql as I work with MSSQL Server and Informix, but for me it works like this: $insert = ifx_prepare(INSERT INTO my_table VALUES ('0'), $connect_id); ifx_do($insert) or die (Query failed); ifx_free_result($insert); By using PREPARE and DO to execute the queries it allows ifx_free_result to release those resources.
Re: [PHP] Freeing Memory
How would you go about ensuring the memory is not exhausted when running a script ? I have a script, which to make it basic ... reads values from files, I create an array of values per file then with a foreach insert values into a table, I have added a line to echo the memory use after each array is done (after insert is done and the foreach is complete for the file) with: - echo Mem SQL: .memory_get_usage() . \n; It gave me this result below: Mem SQL: 8341312 Mem SQL: 8461856 Mem SQL: 8693440 Mem SQL: 9327008 Mem SQL: 9798952 Mem SQL: 10238392 Mem SQL: 10604776 As can be seen the mem usage simply grows, I have added a line after each iteration of the foreach is complete to unset the vars and array ... thinking this would basically clear up the allocated memmory used by the array ... and it would start at 0 again for the next array looped, but obviously this is not quite the answer. The question is then how do you clear memmory then ? I don't know what version of SQL you are using, but I have found that using: mysql_free_result($result); mssql_free_result($result); ifx_free_result($result); Helped my queries run much faster and use less resources. I had something similar to your script where I would read lines from a huge file and then insert the contents into my database. Before adding the above the process would take 20-30 minutes. After freeing the results after each insert my script completed in about 5-8 minutes. Just add that within your foreach loop after you execute your query that inserts the info. Hope that helps. Dan
Re: [PHP] Search Query on two tables not working
Why isn't this working for searching? // Run query on submitted values. Store results in $SESSION and redirect to restaurants.php$sql = SELECT name, address, inDate, inType, notes, critical, cviolations, noncritical FROM restaurants, inspections WHERE restaurants.name '' AND restaurant.ID = inspection.ID;if ($searchName){ $sql .= AND restaurants.name LIKE '%. mysql_real_escape_string($name) .%' ;if(count($name2) == 1){ $sql .= AND restaurants.name LIKE '%. mysql_real_escape_string($name2[1]) .%' ;}else{ foreach($name2 as $namePart){$sql .= AND restaurants.name LIKE '%. mysql_real_escape_string($namePart) .%' ; }}}if ($searchAddress) {$sql .= AND restaurants.address LIKE '%. mysql_real_escape_string($address) .%' ; } $sql .= ORDER BY restaurants.name;; $result = mysql_query($sql); I'm not sure about MySQL, but in Informix my queries will crash when trying to just append the ORDER BY clause by itself. $sql .= ORDER BY restaurants.name;; Also, you have a semi colon before and after the ending quote. TRY $sql .= AND 1 = 1 ORDER BY restaurants.name;
Re: [PHP] Search Query on two tables not working
On Tue, Jul 21, 2009 at 12:41 PM, Miller, Terion tmil...@springfi.gannett.com wrote: Turned off the redirects on the whole script and tried to the the query to echo and these are the errors I got: Notice: Undefined offset: 1 in /var/www/vhosts/ getpublished.news-leader.com/httpdocs/ResturantInspections/processRestaurantSearch.phpon line 89 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/vhosts/ getpublished.news-leader.com/httpdocs/ResturantInspections/processRestaurantSearch.phpon line 119 On 7/21/09 11:32 AM, Kevin Smith ke...@netsmith.ltd.uk wrote: Can you supply the actual generated SQL, I can potentially see a problem, but need to see the final SQL statement. print_r($sql);
Re: [PHP] Alphabetical pagination
I am trying to make a page that displays a-z like a b c d e etc as links then when you click open one it reloads itself and shows only the query results that go with that letter...i'm not getting itI get a page that says ARRAY over and over... What I have so far: ?php if(!isset($_SESSION['RestaurantList'])) { // List not grabbed yet, so run query and store in $_SESSION $sql = SELECT DISTINCT name FROM restaurants GROUP BY name DESC; $result = mysql_query($sql) or die(mysql_error()) ; $count = mysql_num_rows($result); echo $count; while($row = mysql_fetch_array($result)) { $name=array($row['name'],0,1); //$name = array('name'); echo a href=\page.php?name= .$name. \ $name/a\n; } } $alphabet = range('A', 'Z'); foreach ($alphabet as $letter) { echo 'a href=' . $_SERVER['PHP_SELF'] . '?letter=' . $letter . '' . $letter . '/a'; } ? Well, are you opposed to using Javascript? //javascript function script language=JavaScript !-- function searchLetter(letter) { document.my_form.letter.value=letter; document.my_form.submit(); } //-- /script //You could make a hidden form field to store the value of the letter selected. form name=my_form method=POST action=?php echo $_SERVER['PHP_SELF']; ? input type=hidden name=letter value=?php echo $_POST['letter']; ? /form //Perform your query and search only for the letter if it isn't blank. ?php $selected_letter = $_POST['letter']; if ($select_letter != ) { $sql = SELECT DISTINCT name FROM restaurants WHERE name LIKE '$letter%' GROUP BY name DESC; } ? //Print out all your letters ?php $alphabet = range('A', 'Z'); foreach ($alphabet as $letter) { ? //Have the links call a javascript function that updates the letter selected and resubmits the form to perform your new query a href=javascript:searchLetter('?php echo $letter; ?')$letter/a ?php } ? Something like that. I haven't tested any of that code just typed it up real quick to give you an idea of one way to possibly do it. Hope that helps. Dan
Re: [PHP] PHP Print, PDF (w/FPDF), JavaScript
I can't find anything like this in FPDF 1.53 or in the documentation for version 1.60. I'd be interested if you can pinpoint it. Paul Sorry, you need to load a class extension, see the website below: http://www.fpdf.de/downloads/addons/36/
Re: [PHP] PHP Print, PDF (w/FPDF), JavaScript
How can I click a button using JavaScript print function and have it generate a PDF with FPDF and get the PDF printed automagically? It seems I have done this before but I cannot recall what I did. TVMIA! If I remember correctly there is an FPDF command **autoprint()** you can put in at the end of your output to automatically bring up the print dialog...BUT, if you have Adobe Reader 7.0 or newer, you will ALWAYS get a popup security message from Adobe about the application trying to automatically print. From the searches I did, you cannot disable or bypass this warning notification. HTH Dan
Re: [PHP] How to include a java script in a php tag (form)
?php and there is a special $html = ' blablablablabla '; where all the html code is written for the form (table,...). The problem is that I have to include a javascript to be able to send the form to my email address. I don't know where and how to put it. Could someone help me please? Why not just have your Send button call the javascript? //Create your javascript function script language=JavaScript !-- function myScript(){ your email javascript } //-- /script //Create your form ?php All your PHP code; ? //Make your Send button call your Javascript function input type=button name=send value=send onClick=javascript:myScript() HTH, Dan
[PHP] Array Brain Freeze
Hello all, I have the follwoing piece of code: //reference a stored procedure $procedure = Execute Procedure informix.arrest_char($part_id); //run the stored procedure $char_query = ifx_query($procedure, $connect_id); //get the result of the stored procedure $char_result = ifx_fetch_row($char_query); //print out the returned values. print_r($char_result); This all works just fine and I have values returned. What I am trying to do is assign one of the array items to a variable. In the past I have done so like this: $stat_1 = $char_result['stat_1']; But for some odd reason $stat_1 doesn't contain anything. Am I going crazy or am I doing something wrong? Thanks, Dan
[PHP] Re: Array Brain Freeze
Hello all, I have the follwoing piece of code: //reference a stored procedure $procedure = Execute Procedure informix.arrest_char($part_id); //run the stored procedure $char_query = ifx_query($procedure, $connect_id); //get the result of the stored procedure $char_result = ifx_fetch_row($char_query); //print out the returned values. print_r($char_result); This all works just fine and I have values returned. What I am trying to do is assign one of the array items to a variable. In the past I have done so like this: $stat_1 = $char_result['stat_1']; But for some odd reason $stat_1 doesn't contain anything. Am I going crazy or am I doing something wrong? Thanks, Dan Please disregard...the brain freeze went away and i spotted the problem. The array value name had a [ in it. So when referencing it to assignmy variable I wasn't including the additional bracket. :) Dan
Re: [PHP] Whats the correct syntax for using query results in a new query
I'm trying to use the AdminID that returns from query #1 in the WHERE AdminID = AdminID from Query 1 Okay, I think I understand what you are trying to do. //query 1 $query1 = SELECT UserName, AdminID FROM admin WHERE Retail1 = 'YES'; $result1 = mysql_query ($query1) ; while ($row1 = mysql_fetch_row($result1)){ $admin_id = $row1['AdminID']; //query 2 $query2= SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID, FormName, Status, Notes, pod FROM workorders WHERE AdminID = $admin_id; $result2 = mysql_query ($query2) ; $end_result = mysql_fetch_row($result2); echo $end_result['WorkOrderID']; echo $end_result['CreatedDate']; }
[PHP] Execute EXE with variables
Hello all, Can someone point me in the right direction? I'm trying to call an EXE from PHP and pass it two variables. I looked at the exec() command and I see that this can call the executable, but I don't see that it can pass the variables to it. Dan
Re: [PHP] Execute EXE with variables
Use the system() command, and enclose both your command and its parameters in a pair of single quotes, as: system('mycmd -a alfa -b bravo'); Paul -- Paul M. Foster Using both exec() and system() I am getting the error: Unable to fork
Re: [PHP] Using DLL with PHP
MAYBE a little closer to a solution! //VB for Reference Private Declare Function DTM_CONVDMSToMultiTIFF Lib D32_CONV.DLL _ (ByVal FullPathFrom As String, ByVal FullPathTo As String) As Integer Public Function hello(ByVal name As String) As String hello = Hello name World! End Function Public Function DMStoTIFFconv(ByVal FullPathFrom As String, ByVal FullPathTo As String) As String Dim DMSconv As Integer DMSconv = DTM_CONVDMSToMultiTIFF(FullPathFrom, FullPathTo) End Function //PHP Code ?php function Hello() { $new_com = new COM(DMStoTIFF.conv); $output=$new_com-hello('Happy'); // Call the hello() method echo $output; // Displays Hello World! (so this comes from the dll!) $convert=$new_com-DMStoTIFFconv('C:\\TEST\\04186177.dms','C:\\TEST\04186177.tif'); } Hello(); ? So, previously I was having issues calling the D32_CONV.DLL... I think I am past that now. If I comment out $convert=$new_com-DMStoTIFFconv('C:\\TEST\\04186177.dms','C:\\TEST\04186177.tif'); the Hello Happy World text prints to the screen no problem. But when I try to access the VB to call the actual DTM_CONVDMSToMultiTIFF function I am getting one of two errors. I am either timing out, or getting a message saying incomplete headers. The D32_CONV.DLL file is a conversion library that will convert a file from DMS format to TIF based on two parameters. Since this function is converting a document, do you think my problem is trying to assign that to the $convert variable instead of a file output location?
Re: [PHP] Using DLL with PHP
Alrighty, so I went a different route... I created my own ActiveX DLL...one that I know I can register. Starting out really simple: //My VB code Public Function hello() As String hello = Hello World! End Function //My PHP code ?php function Hello() { $new_com = new COM(DMStoTIFF.conv); $output=$new_com-hello(); echo $output;} Hello(); ? So, after I register the DLL on the server my PHP page is correctly displaying the Hello World! dialog. What I'm having problems with now is trying to pass a variable to the DLL. Shouldn't I be able to do this just like any other PHP class/function?
Re: [PHP] Using DLL with PHP
It doesn't appear that your function accepts a parameter. What does this do: //VB Public Function hello(ByVal name As String) As String hello = Hello name ! End Function //PHP echo $new_com-hello(Dan); -- Thanks! -Shawn http://www.spidean.com Shawn I tried what you suggested but it returns the following: *Fatal error*: Cannot pass parameter 1 by reference
Re: [PHP] Using DLL with PHP
Just guessing as I haven't used the PHP COM stuff, but what do you get if you change ByVal to ByRef? -- Thanks! -Shawn http://www.spidean.com Ooops! My fault! I created a new dll so I could keep the currently working one and forgot to register it.. Registered and it allowed the passing of the variable and the display came out correctly! Baby Steps... Now I just need to incorporate a Lib .dll call into my working activex dll and I might be on my way.
Re: [PHP] Using DLL with PHP
Check out the com [www.php.net/com] functionality Bastien Alrighty, I'm trying to use the COM function, but not getting much of anywhere. This is what I have: ?php // The VB function for reference /*function DTM_CONVDMSToMultiTIFF Lib D32_CONV.DLL _ (ByVal FullPathFrom As String, ByVal FullPathTo As String) As Integer*/ //Create a function in PHP to call the DLL function DMStoTIFF() { $my_com = new COM('D32_CONV.DLL'); $output = $my_com-DTM_CONVDMSToMultiTIFF(C:\TEST\04186177.dms, C:\TEST\04186177.tiff); } DMStoTIFF(); ? But I am getting the error below: *Fatal error*: Uncaught exception 'com_exception' with message 'Failed to create COM object `D32_CONV.DLL': Invalid syntax Any ideas?
Re: [PHP] Using DLL with PHP
I can't help much, but this might get you started. 1) Does the DLL you are trying to use actually supports COM. I know some don't. 2) I'm pretty sure that the string you pass to new COM('...') should be the name the class as registered with Windows, not the actual file name. They are usually something like 'Scripting.FileSystemObject', 'word.application', 'ADODB.Recordset', etc. Andrew The DLL I am trying to work with was written by an outside agency. Their application uses this dll to convert DMS images (Their proprietary format) to TIFF images. Naturally they are not very forth coming to share the functionality of their software, but I was able to get the VB function that calls the DLL for conversion. Private Declare Function DTM_CONVDMSToMultiTIFF Lib D32_CONV.DLL _ (ByVal FullPathFrom As String, ByVal FullPathTo As String) As Integer So, I was hoping to be able to call that DLL in PHP and pass it the two values I specify in my application. In order to be used by COM is the DLL required to be placed in the SYSTEM or SYSTEM32 folder? Or does it have to be a DLL that can be registered? Or placed in the SYSTEM Path?
Re: [PHP] Using DLL with PHP
I believe you do have to register it with regsvr32 for it to be visible. I think the GUID that Todd mentioned might even work, but I've only ever used the ProgID. If you don't know the ProgID that is registered, you should be able to find it in the Windows registry after you've registed it with regsvr32. If you search for the file name, it should find an entry somewhere under \HKEY_CLASSES_ROOT\CLSID\(some GUID)\InprocServer32 that has a value of the full path to your DLL file. The ProgID is the next key down below InprocServer32, labeled aptly ProgID. Andrew I might be out of luck. When I try and run regsvr32 to register the file it says the DLL was loaded, but the DllRegistryServer entry point was not found. This file cannot be registered.
Re: [PHP] Using DLL with PHP
H, maybe it's not a problem with the DLL I'm trying to access because just doing a simple: $my_com = new COM(Excel.Application); Gives me the same error: *Fatal error*: Uncaught exception 'com_exception' with message 'Failed to create COM object `Excel.Application': Invalid syntax ' I've checked my PHP.ini and COM is enabled...
[PHP] Using DLL with PHP
Howdy, I'm looking for a little guidance here. I'm trying to re-write a VB function in PHP. This is the function I'm working with: Private Declare Function DTM_CONVDMSToMultiTIFF Lib D32_CONV.DLL _ (ByVal FullPathFrom As String, ByVal FullPathTo As String) As Integer Naturally I would start off with function() from PHP as well and I will also already have my two variables that I need to pass to the DLL: $FullPathFrom = this\is\my\path; $FullPathTo = this\is\my\path; function DTM_CONVDMSToMultiTIFF ( ) But I am unsure of how I would call and pass the variables to the DLL. I've looked into W32api, but not sure if that's even what I need. Any ideas? Thanks, Dan
Re: [PHP] Garbage Collection
Hi gang: A related question to my last Clarity needed post. I have a tutor table (showing all the tutors), a course table (showing all the courses), and a course-to-tutor table (showing all the instances of what tutor teaches what course). Okay, everything works. Whenever I want to find out what courses a specific tutor teaches OR what tutors teach a specific course, I simply search the course-to-tutor table and bingo out pops the answer. Now, how do you handle the situation when a tutor quits or when a course is no longer offered? If I search the course-to-tutor table for all the tutors who teach a course and find a tutor who is no longer there OR search the course-to-tutor table for all the courses a tutor teaches and find a course that is no longer offered, how do you handle the record? I realize that if either search turns up nothing, I can check for that situation and then handle it accordingly. But my question is more specifically, in the event of a tutor quilting OR removing a course from the curriculum, what do you do about the course-to-tutor orphaned record? As I see it, my choices are to a) ignore the orphaned record or b) delete the orphaned record. If I ignore the record, then the database grows with orphaned records and searches are slowed. If I delete the orphaned record, then the problem is solved, right? I just want to get a consensus of how you people normally handle it. Do any of you see in danger in deleting an orphaned record? Cheers, tedd I guess that all depends. If you want some kind of historical log of what tutor taught which course and which courses have previously been offered then I wouldn't delete the records. Instead I would and something like a Active column and use simple Y and N vaules to mark each tutor or course as active and then just re-write your query to only pull tutor's/courses with the Y flag. That would give you a current listing of active courses and who teaches them, and also retain the historical data if it need to be referenced later. If you don't care about historical data, you could just do a DELETE FROM my_table where course/tutor id = x But I would recreate an index on the table after deletion of records to keep the speed crisp. Dan
Re: [PHP] Preserving History
Hi gang: To further the Garbage Collection thread on to another level (i.e., preserving history) please consider this: Okay, let's say we have a table containing all the instances of tutors teaching courses. A record might look like this: Course-to-Tutor table course_id = 123 tutor_id = 7 date_active = 2/4/9 date_inactive = null The above record was assembled from the following recrods: Tutor table: id = 7 name = joe Course table: id = 123 title = Introduction to Moonshine Okay, so let's now delete the course Introduction to Moonshine! At the first opportunity to search the Course-to-Tutor table we find that the course 123 is now absent from our database and as such we set the date_inactive field -- it won't be considered again. Okay, so what does that tell us about the history? It only provides that at one time joe taught an undefined course. Furthermore, if joe quits, then we only have a record that says someone with an id of 7 taught a course with an id of 123 -- that doesn't make much sense, does it? Now, if we reconsider the Course-to-Tutor table and instead of putting in the tutor_id and course_id, we put in the actual name of the tutor and title of the class, then at least we have a history that makes sense. However by doing that, we violate the primary principle of a relational database by creating redundant data. I guess that one can say that if we never actually delete the tutor nor the course, but instead just make them inactive as well, then we have solved the problem -- is that the answer? In any event, what problems do you foresee if I used the actual names and titles for the Course-to-Tutor table instead of their id's? After all, the instance records would retain a simple history of what happened regardless of deletions AND a search for Introduction to Moonshine should be essentially as fast as a search for 123 if both fields are indexed, am I right or wrong? Cheers, tedd You only need to use ONE value in both tables. tutor_table: tutor_id = 7 first_name = joe last_name = smith active_tutor = Y course_table: course_id = 123 tutor_id = 7 title = Introduction to Moonshine active_course = Y A crude query to return all active tutors and their courses would be: SELECT tutor_table.first_name, tutor_table.last_name, course_table.title FROM tutor_table, course_table WHERE tutor_table.tutor_id = course_table.tutor_id AND tutor_table.active_tutor = 'Y' AND course_table.active_course = 'Y' That will return the course title and tutor name for all active events Hope that helps. Dan
Re: [PHP] calculate the time that day ends
Hi gang, I was wondering if there is way to find out what is the time that every day ends? I am planning to add this to the first page on an interface I am developing. -- Thodoris Doesn't every day end at 23:59:59? the next second would be 00:00:00...the beginning of a new day! :) So to put this time into a variable you could do: $end_of_day = mktime(23, 59, 59, date(m), date(d), date(Y); that will give you the value for today (mm/dd/) at 23:59:59.
Re: [PHP] Another beginner question
On Tue, Jan 13, 2009 at 10:17 AM, Gary gwp...@ptd.net wrote: I have successfully set up the testing server, now I would like to test it out on the remote server, but put does not seem to be working. I saved the php document, click put, nothing seems to happen. I am connected to the remote server, but when I put, nothing happens. The file is in the local root file, the local and remote information has not changed. I do get this error The sites testing and remote servers are different. This scenario is not supported by the Site Wizard, when switching from basic to advanced tabs in site manager. What am I missing? Thank you Gary This sounds like a Dreamweaver question, not a PHP question... If you go to Site - Edit Sites Under Local Info you input the information for the server you develop your application on Under Remote Info you input the information for the server you would like to Put files on Under Testing Info you input the information for the server you would like to use to View your pages. Your Remote and Testing servers should ideally be the same.
[PHP] Suggestions?
Hello all! I have written some code that will calculate all static and floating holidays. I have also written some code that will act as a business day counter. My application currently determines a set number of business days to count. (2 business days and 7 business days from today) This part works great and gives the results I want. What I need to do is tie in my pre dertermined static and floating holidays and factor those into the busniess day counter. I was thinking of putting the holidays into an array and then doing a check to determine if any date in the array equaled today's date through the ending date. But I'm drawing a blank on how to create the array. // Create an empty array $holidays = array(); But then how do I put each holiday value into the array as it is calculated? Can I assign it that way? Or should I calculate all of the values and then build the array at the end? Or should I not even use an array? Thanks, Dan
Re: [PHP] Suggestions?
On Tue, Jan 13, 2009 at 2:09 PM, Eric Butera eric.but...@gmail.com wrote: Are you asking how to do $holidays[] = date; array_push($holidays, date); ? If you were generating dates to compare against today tho, you could just return upon a match at that point and not even store them. No point in creating some big array in a loop only to loop through it again when you could have done it the first time around. I'd put this into a function though so that I could return out upon a match. Not to only compare against today. I want to determine if any of the holiday dates are equal to or between dates in a date range. For example: I need to calculate 2 business days from today. Today is Wednesday December 23rd. December 24th and 25th are holidays. December 26th and 27th are the weekend. So 2 business days from December 23rd would be December 29th. So multiple holiday dates could fall into the range I am trying to get so I would think I'd need to loop through all of the holidays to catch all of the holidays that may fall within the range and add an additional day as needed to get the correct business day.
Re: [PHP] Suggestions?
On Tue, Jan 13, 2009 at 2:14 PM, c...@l-i-e.com wrote: Hard to say without knowing the data structures... You can't do a simple count of the holidays and add that, because you might end up with yet another holiday in the result. Start at 12/23 and want to add 6 business days. You find 1 holiday in between, so you add 7 business days and end up on New Year's Day, a non-business day. 12/23 12/24 12/25 X 12/26 12/27 12/28 12/29 12/30 12/31 01/01 X I think MySQL has built-in holiday / work day calculations, come to think of it... Exactly, ceo! That's why I'm thinking of creating the array and then running a foreach() loop on the array. $day = date(w); $today = date(m-d-Y); if ($day == 4 || $day == 5) { $two_day = mktime(0, 0, 0, date(m), date(d)+4, date(Y)); $two_day = date(m-d-Y, $two_day); } else { $two_day = mktime(0, 0, 0, date(m), date(d)+2, date(Y)); $two_day = date(m-d-Y, $two_day); } foreach ($holiday as $h) { if ($h = $today $h = $two_day) { $two_day = mktime(0, 0, 0, date(m, $two_day), date(d, $two_day)+1, date(Y, $two_day)); $two_day = date(m-d-Y, $two_day); } } That should add a day for each instance of a holiday that falls between the dates, right?
Re: [PHP] Data trasfer between PHP pages
Hi, I have one form where user fills data using radio buttons. Only one answer goes from here to another page. FORM 1 form action=form2.php method=post input type=radio name=myname value=Answer 5 id=1 / label for=15/label br / input type=radio name=myname value=Answer 1 id=2 / label for=21/label br / input type=radio name=myname value=Answer 3 id=3 / label for=33/label br / input type=submit value=Enter / /form --- FORM 2 There is another page has a form with 14 fields PLUS I need the data of the previous form to be hidden somewhere in this form. Once this form is submitted I need to put the combined data into the database. I know this is so simple. But not sure why this is not working. I tried to use ?$_GET[myname] ? from the first form but its not working. My module page has to go live tomorrow morning, I am stuck, please help. Thanks, Chris The submission method you are using on the first page says, form action=form2.php method=post Since your methodis post you need to use $variable = $_POST[' '] instead of $_GET[' '] That will give you the value from your previous page and then you can just do: input type=hidden name=myname value=?php echo $variable; ? And that will assign your posted value to a hidden field like you wanted.
Re: [PHP] Couple of beginner questions
so would I be correct that the only advantage to having a page with a php extension is that you can use a testing server? There are FAR more benefits! 1) PHP is FREE! So you save money from the get go 2) PHP is open source! So it is constantly being updated and improved by users/devs. 3) PHP is processed on the SERVER. This frees up CPU usage on the user's workstation. 4)PHP can retieve data from a centralized database which makes dynamic content easier to use. 5) Since PHP is server side, you are not reliant on the end users to have specialized plugins/software to view your pages. 6) PHP is easy. IMO one of the easier languages ot learn. 7) PHP has a great community. (See peopel on this list) And many many more reasons you will learn as you go! :)
Re: [PHP] Been staring at the code for too long...
mysqli_stmt_prepare($stmt, UPDATE database.table ( FName, LName, email, phone, url, record, subscribed, date, IPAddress, Business, Address1, City, State, Zip, Coffee, Meeting, areaPlans) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)); Warning: mysqli_stmt_bind_param() [function.mysqli-stmt-bind-param]: invalid object or resource mysqli_stmt in /public_html/purl/purlprocess.php on line 67 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '( FName, LName, email, phone, url, recor' at line 1 Am I just going crazy or is there something really wrong? Okay.. I'm done... First stupid question of the year... Only 3,349,587 more to go for the year! :P I don't work with MySQL, but shouldn't the UPDATE syntax be something like this: mysqli_stmt_prepare($stmt, UPDATE database.table SET FName = ?, LName = ?, email = ?, phone = ? WHERE id = ?);
[PHP] Re: [PHP-DB] data from db to a page and then to another page
On Wed, Jan 7, 2009 at 4:54 AM, Mika Jaaksi mika.jaa...@gmail.com wrote: I already can get the data from database to a page. Now I want to make link from that data to next page and on that new page it should show all the data that is related. example: data from database -- page1 where listed: band1 (a href) band2 (a href) band3 (a href) ... and when clicking for example band3 -- page2 where listed band info: bandname bandhistory bandmembers ... So, how should I do this? Should I somehow use $_POST method to send/deliver band_id to the next page? You could do several things. 1) Use javascript to make a link using the band3 value within the Javascript to pass the ID to the next page. Example: Have a Javascript function - script language=JavaScript !-- function openWin(band_id) { var link link = my/directory/display.php?band_id=' + band_id; MyWin = window.open(link,OpenPage); MyWin.focus(); } //-- /script And then call that function when you click on the band you want. a href=javascript:openWin('?php echo $band_id; ?')?php echo $band; ?/a 2) You could use form objects (radio buttons/check boxes/dropdown box etc) to pass the band_id value via POST Then on your second page all you would have to do is get the value. Example: input type=radio tabindex=1 name=band value=?php echo $band_id; ? input type=radio tabindex=2 name=band value=?php echo $band_id; ? input type=radio tabindex=3 name=band value=?php echo $band_id; ? On the second page you would simply check the posted value of you band radio input: $band_id = $_POST['band']; Hope that helps. Dan
Re: [PHP] redoing website after 7 years
but, I'm more concern does client has to pay the changes/upgrade or it's still my obligation? Of course you charge him. Christ if I was expected to maintain stuff gratis that I wrote 7 years ago I'd be mullahed. -- Richard Heyes I agree with Richard. I bought a car 7 years ago. I decided to make some modifications to the motor and now the car won't start! Do you think the car company is going to give me a brand new car because I messed it up? Nope, I'm going to have to buy a new car. :)
[PHP] Re: [PHP-DB] Re: data from db to a page and then to another page
Thanks for the aswers, but there is still some problems. I tested this code(below) and it works but when I add it to the rest of my code it stops working. Here's the working code: page1: ?php $bandname = Someband; ? form name=goto_info action=band_info.php method=post input type=hidden name=bandname value=?php echo $bandname; ? a href=band_info.php?bandname=$bandname onclick=goto_info.submit(); return false;?php echo $bandname; ?/a /form and page2: Bandname is ?php echo $_POST[bandname]; ?! _ Now, here's the one I've been fighting with: ? include(XXX.inc.php); mysql_connect($host,$username,$password); @mysql_select_db($database) or die( Unable to select database); $query=SELECT * FROM band; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo bcenterBands/center/bbrbr; ? table border=0 cellspacing=2 cellpadding=2 tr thfont face=Arial, Helvetica, sans-serifbandname/font/th /tr ? $i=0; while ($i $num) { $bandname=mysql_result($result,$i,bandname); ? tr form name=goto_info action=band_info.php method=post input type=hidden name=bandname value=?php echo $bandname; ? a href=band_info.php?bandname=$bandname onclick=goto_info.submit(); return false;?php echo $bandname; ?/a /form /tr ? ++$i; } echo /table; ? For some reason this doesn't post bandname to band_info page... Your while () { } loop looks strange to me. You are doing a SELECT * from your database and basically want to output each result with an assigned $bandname, right? If you're selecting all records, that you shouldn't need to do a row count or use the $i counter. You could simply do this: script language=JavaScript !-- function submitForm(bandname) { document.goto_info.bandname.value=bandname; document.goto_info.submit(); } //-- /script ? include(XXX.inc.php); mysql_connect($host,$username,$password); @mysql_select_db($database) or die( Unable to select database); $query=SELECT * FROM band; $result=mysql_query($query); mysql_close(); ? bcenterBands/center/bbrbr form name=goto_info action=band_info.php method=post input type=hidden name=bandname value= table border=0 cellspacing=2 cellpadding=2 tr thfont face=Arial, Helvetica, sans-serifbandname/font/th /tr ? while ($row = mysql_fetch_row($result)) { $bandname=$row['bandname']; ? tr a href=javascript:submitForm('?php echo $bandname; ?')?php echo $bandname; ?/a /tr ? } ? /table /form
[PHP] Re: [PHP-DB] Re: data from db to a page and then to another page
On Wed, Jan 7, 2009 at 3:01 PM, Mika Jaaksi mika.jaa...@gmail.com wrote: Thanks! I got it working... Excellent, happy to help.
Re: [PHP] Since I speak with some of you more than people I see in person....
And as a side note (some of you already know): for my wife and I closing out the year, we heard the heartbeat of our first child for the first time today in the ultrasound. Nothing else will ever again matter as much to me as what I am about to embark upon. I don't think any song or sound I've ever heard in my entire life was as beautiful as those few seconds. My heart literally feels so full that it could burst at any moment. Congrats, Dan! I'm right there with you! My wife is 7 months preggo right now! Wait until you get to feel the kicks every day and see little hands poking out from her belly. Totally awesome! My New Years Resolution is going to be getting a raise! Well, I hope you all have a great New Years! I promise to not ask anymore PHP questions until next year! :) Dan
Re: [PHP] First record not diplaying
?php // Good to go if (0 == $totalRows_rsSearch) { echo h3Sorry no products were found/h3; } else { echo h3Please click on a product for further information./h3; while ($row_rsSearch = mysql_fetch_assoc($rsSearch)){ echo div class=\productitem\img src=\products. $row_rsSearch['product_image'].\ div class=\text\ h3. $row_rsSearch['product_name']./h3 p class=\style1\. $row_rsSearch['product_subtitle'] . /p a href=\products. $row_rsSearch['product_url'].\View Product/a div class=\clear\/div /div div class=\clear\/div center /center /div; } } ? What is your value for $row_rsSearch ??
Re: [PHP] First record not diplaying
Hi, I seem to have a bug in my code but can't see why. My first record does not display when I run a search. Can anyone spot what I have done wrong? Thanks if (0 == $totalRows_rsSearch) { echo h3Sorry no products were found/h3; } else { echo h3Please click on a product for further information./h3; while ($row_rsSearch = mysql_fetch_assoc($rsSearch)){ echo div class=\productitem\img src=\products. $row_rsSearch['product_image'].\ - Gary Maddock-Greene Is this another one of your classes? I see your email address links to a web page created for a class. Without the rest of the code (the code above what you have placed) and the end of the echo line you have provided, all any of us can do is a guess. However one thing to note, this list was not created to help you with your homework and with the previous postings you have written, it is pointedly answering different places you have stumbled in your work and haven't checked your book, the online resources, or a TA. Wolf Like Wolf said...we need more code :) My guess would be that you probably have the default value of your row count set to start at 1...but the results of an array start at 0...therefore your first row is being cutoff?
[PHP] Printing
Hello all, Could someone please point me in the right direction for printing files through PHP? I already have my application setup so that it creates documents and saves them to a folder. How would I go about printing all of the files in the folder via PHP? I've looked into the Print functions in the manual ( http://us2.php.net/manual/en/ref.printer.php) but this does not seem to be the right thing to use to print documents that already exist. Thanks, Dan
Re: [PHP] Printing
Do you want to print this on your office printer or on the website users printer? If you are looking for away to print it on their printer, why not just grab all the files that need to be printed, make a PDF of it, and then use the browsers print feature? -- Jason Pruim japr...@raoset.com 616.399.2355 I want it to print to the users local printer. Basically the user has a form and based on their search criteria they will get multiple results. Next to each result I have a checkbox that the user will use to select the documents they want to print. Once they have selected everything they want to print, they click on a Print Selection link. The checkboxes all have the same name but different dynamically assigned values, so once they click to print, an array of values for the checkbox name is passed to my next page. I have a for () loop on the next page that extracts each individual value and uses it in a query to extract information and build a pdf which is automatically output to a file. Once a PDF has been generated I want to send it to the users printer to be printed.
Re: [PHP] Printing
Does it save them to a folder on the server? Or does it save them on the client? If it is on the server then the server would have to send the docs to a printer queue. If it is on the client PHP cannot really do anything about. PHP cannot force the client to print but it could send the docs to the client once a request has been made. Yes, it saves the created documents to a folder on the server. Since any user could request to print the same document I first check to see if the document already exists. If it does exist I naturally want to skip the creation process and just print it and move on to the next selection. I have another process that clears out this folder once every 24 hours so it doesn't accumulate a massive store of files.
Re: [PHP] Printing
You can't, the best you can do is send the PDF down and let the user choose to do with it what they will -- Bastien So you think I should try and look into a way to have FPDF append each document to the already created document, and once all pages have been added to the PDF force it back to the user to open in the broswer?
[PHP] FPDF Printing Ideas?
Hello all, I'm looking for some suggestions. I'm writing a new application that generates PDF's on the fly with FPDF. Basically I have a search page where you can search for customer records. Once your search has returned the records you can then click on a link which will send the record_id to the page that generates the PDF. And while this brings up the PDF and I can click on the printer icon to print the document, I want to be able to select multiple documents to print at one time. Example: [ ] 12345 [ ] 12346 [ ] 12347 [ ] 12348 [ ] 12349 [ ] 12350 I want to select the first and last record to be printed, so I was thinking I could od several things here. Since the Output() of FPDF cannot be sent directly to a printer I was going to 1) When someone clicks a checkbox, use the javascript onChange action to generate and save the PDF in the background. So, when someone clicks a checkbox, the page that generates my PDF would run without the user seeing it...this page would save the PDF to a folder on the server and once all checked items are selected the user will simply click on a Print Selection link which will point to a PHP page that just says to print *.pdf from that folder. 2) Allow the user to check all the documents they want to print and then when the Print Selection link is clicked, pass all of the checkbox values via $_POST to a new page which will run a loop that generates, prints and deletes the files. Does anyone have any experience or any better ideas to accomplish a selective multiple document print for documents that don't initially exist? Thanks, Dan
Re: [PHP] FPDF Printing Ideas?
On Tue, Dec 16, 2008 at 2:32 PM, c...@l-i-e.com wrote: Just generate a much larger PDF with all the pages they asked for and call it done. :-) I don't think I can do it that way unfortunately. They will be printing 100-300 records in bulk...the amount of time it would take to generate one giant PDF file for all of the records would probably be insane and definitely much longer than the users are willing to wait. And also I don't believe you can loop the FPDF functions without it throwing an error.
Re: [PHP] MSSQL_CONNECT problem
Sorry for top posting, that's how my email client sets up the reply... Anyway, I don't know what CLI is? I see the error on the web. As for a DSN, I didn't think I need one connecting this way. That is why the uname, password, database is supplied, no? This should be a dsn-less connection Either way - I tried adding a DNS on the web server, that points to the SQL database, and that connection works...but the code I'm using from the web page still does not If I use the code you gave me, this is what I get: Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: INTRA_SQL,1433 in D:\Inetpub\wwwroot\cratos\test.php on line 2 Fatal error: Call to undefined function mssql_error() in D:\Inetpub\wwwroot\cratos\test.php on line 2 Please advise... Try something like this: $dbhost=SERVER\\INSTANCE_NAME,PORT; $dbuser=USERNAME; $dbpass=PASSWORD; $db_connect=mssql_connect($dbhost,$dbuser,$dbpass) or die ('Server connection failed'); $mssql_database = mssql_select_db(DATABASE, $db_connect) or die ('DB selection failed');
Re: [PHP] MSSQL_CONNECT problem
Try something like this: $dbhost=SERVER\\INSTANCE_NAME,PORT; $dbuser=USERNAME; $dbpass=PASSWORD; $db_connect=mssql_connect($dbhost,$dbuser,$dbpass) or die ('Server connection failed'); $mssql_database = mssql_select_db(DATABASE, $db_connect) or die ('DB selection failed'); Same thing: Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: \\10.10.103.222\INTRA_SQL,1433 in D:\Inetpub\wwwroot\cratos\test.php on line 5 Server connection failed Is INTRA_SQL your instance name or database name? If it is the instance name, is that instance setup to use 1433 as the port? I know 1433 is the default port for MSSQL, but the majority of people change that.
Re: [PHP] MSSQL_CONNECT problem
Is INTRA_SQL your instance name or database name? If it is the instance name, is that instance setup to use 1433 as the port? I know 1433 is the default port for MSSQL, but the majority of people change that. Correct - intra_sql is the instance, yes, it's using default port 1433 (which is also specified in the php.ini file)I've tried connecting with and without specifying the port - but both ways don't work Perhaps you have a different version of PHP than me...but nowhere in the php.ini file have I had to put in a port number for a MSSQL Server. That seems like a problem since PHP could need to connect to any number of SQL Servers with any port number. From your PHP server, open a command prompt and ping your SQL server. Try pinging by IP address and by server name. See if you get a response from both. NOTE: Are you running PHP and MSSQL Server on the same box?
Re: [PHP] MSSQL_CONNECT problem
Can't seem to connect with MSSQL_CONNECT. The function IS available. I'm in a Windows environment, connecting to a SQL 2000 instance. My code: mssql_connect('INTRA_SQL,1433', 'uname', 'password'); mssql_select_db('database'); I've tried leaving the port out, tried using server IP address, all to no avail. I've copied the ntwdblib.dll from my SQL 2000 box to my PHP directory on the web server - no go. (this was suggested on the php site). mssql.secure_connection = off (in the php.ini file) extension=php_mssql.dll (is also included in the ini file) Keep getting error message: Unable to connect to server Does anyone have any ideas? Thanks! Dave Dave, For my connection I didn't copy the ntwdblib.dll file from the SQL Server and paste it onto the PHP server...I believe there was an older version of the ntwdblib.dll that I had to download...the file had a modification date of I think 11/2003. Things to check. extension=php_mssql.dll uncommented in your PHP.ini See if your PHP server can talk to your SQL Server. I would assume they are both inside the DMZ and that your DNS resolves the server names, correct? When making your connection try doing it like this: //Assign the server connection to a variable $connect = mssql_connect('SERVERNAME, 'USERNAME', 'PASSWORD'); //Select your database and reference the connection mssql_select_db('DATABASE', $connection);
Re: [PHP] implode()
On 11/18/08, Terion Miller [EMAIL PROTECTED] wrote: I have read the whole forum at php.net on implode and I still don't get why this one does not work if (isset($_POST['BannerSize'])){$BannerSize = implode($_POST['BannerSize'],',');} else {$BannerSize = ;} someone please help You appear to have it backwards? Using implode() you should have your glue (the value you want to identify to implode on) before your $variable. It looks like you are trying to implode on a comma, correct? So using the proprer format of implode(glue,variable) you should so something like: implode(',',$_POST['BannerSize']); Dan
[PHP] CREATE question
All, Is it possible for us to use PHP to create temp tables in our database? Ironically, up until this point I have only needed to use SELECT statements. But now, to speed up the processing time of a large query I would like to create a temp table and then reference the temp table in another query. I've tried stuff like the below: $temp_query = create temp table my_temp_table( date date, code char(3), loc char(3), time DATETIME HOUR TO MINUTE, matter_id int, name char(25) ) WITH NO LOG; $do_query = ifx_query($temp_query, $connect_id); But all that does is give me an ifx_prepare fails message. Can we not use the ifx_query, mssql_query, mysql_query functions to create tables? Can they only be used to select data? Thanks in advance, Dan
Re: [PHP] CREATE question
On 10/30/08, Daniel Brown [EMAIL PROTECTED] wrote: On Thu, Oct 30, 2008 at 2:19 PM, Dan Shirah [EMAIL PROTECTED] wrote: Is it possible for us to use PHP to create temp tables in our database? [snip!] But all that does is give me an ifx_prepare fails message. (Forwarded to PHP-DB as well.) Dan, make sure Informix is set to allow that user to use the CREATE syntax. Also, not sure about IFX, but with other SQL databases - including MySQL - you have to use the full word `TEMPORARY`, not just `TEMP`. -- /Daniel P. Brown http://www.parasane.net/ [EMAIL PROTECTED] || [EMAIL PROTECTED] Ask me about our current hosting/dedicated server deals! Ah! You both may be right. I was running my entire using AQT and it ran fine without any problems but once I pulled it into my web application it took a swan dive. You're probably totally right, of course it could create it in AQT because I'm connecting to it with my credentials, whereas the web application is connecting as a different user. Thanks guys, I'll check out my permissions and hopefully that's all it is. Just an FYI, the use of temp instead of temporary does work in Informix :)
[PHP] Building an array, kind of?
TGIF? Apparently my brain isn't working this Friday. I'm trying to query my table to get the first 16 ID's. I then want to assign the ID's to a variable and have them comma seperated. // My query to select the first 16 rows $get_charges2 = SELECT FIRST 16 * FROM history WHERE id = '$id; // Executing the query $charge_result2 = ifx_query ($get_charges2, $connect_id); How would I assign the result to a variable? For instance, say my query returns rows like: 1234 1235 1236 1237 1238 1239 How would I go about putting that in a variable to equal 1234,1235,1236,1237,1238,1239 ?
Re: [PHP] Building an array, kind of?
from memory. $var=''; while($row = mysql_fetch_array($charge_result2)) { $var .= $row['id'] . ','; } cheers, tedd Thanks all! It works and here is the code I used: $get_charges2 = SELECT FIRST 16 * FROM history WHERE id = '$id; $charge_result2 = ifx_query ($get_charges2, $connect_id); while ($charge_row2 = ifx_fetch_row($charge_result2)) { $charges .= $charge_row2['id'].,; }
Re: [PHP] Search functionality
Its pretty straight forward, you create a query that extracts the name and id of the records with a relevant where clause created on the fly. When outputing the data, each record gets created as a link that then loads another page/div with the total dataset for that record. The question for you is how you want the interface for the search to work. You can provide a dropdown with some choices (date, zip, etc) and a text input / date input picker to allow the user to enter the data. This then gets submitted and runs the query Correct, right now each record is displayed on the screen as a link. When the link is clicked a query runs to pull all of the related data and displays it as a subset of items under the main link. The problem is, since I am not pulling all of the detail when I run the initial query, what would be the best way to find the search results when they will most liely be contained in the data I did not initially pull.
[PHP] Search functionality
Hello all, I'm looking for suggestions on how to create a search function within my application. First I'll give you an overview. At the top of my page I have a form that contains name and date fields. When a user puts in some data and selects Search a simple column of results will be displayed on the left side of the screen. Example: User searchs for a date of 09/22/08 and a name of Customers. In the left column a list of all customers for that day will be generated. There is A LOT of detail associated with these customer results therefore all data such as name, address, zip code, order number etc is not pulled from the database upon initial search. Instead, if a user clicks a customer name a seperate query will run and retrieve all of the pertinent data and provide a bulleted list under the customer name. What my vendor wants me to do is provide a way for someone to search through all the customers including the details that I do not initially display to allow them to find specific data. Such as finiding a record with a specific zip code. They then want to be able to click next to go to each consecutive record with that zip code. Any ideas on how to do this since all that data is not initially pulled in?
Re: [PHP] ODBC Functions MS SQL Server 2005
On 9/18/08, Dan Joseph [EMAIL PROTECTED] wrote: Hi, Anyone else using the odbc_* functions to interact with MS SQL Server 2005? I'm having a problem getting odbc_num_rows() to return anything other than -1 when querying a stored procedure. I can get it to work using Top in a normal query (non-stored procedure). SELECT Top 100 * FROM Table if I do an odbc_num_rows( result ) on that, I get the number of rows. However... EXEC ProcedureName @Var = 'value' if I do an odbc_num_rows( result), I get -1. The same is true if I did a straight SELECT * FROM Table. I've tried putting Top in my query in the stored procedure. Right now I'm either doing an extra query for @@ROWCOUNT, or I'm doing two result sets, a counting query, and then the normal query. I am concerned about performance in doing the two queries, and with @@ROWCOUNT, I feel I'm just adding extra things to the code that may be unreliable? From what I've read, its something with the ODBC driver, and updating the ODBC driver isn't an option. Anyone else having this problem? Any suggestions? -- -Dan Joseph Dan, If you already have your results in an array, try using count($result); That should count the number of results returned to your result array. Or you could try uncommenting the mssql extension in your php.ini file and then try using: mssql_num_rows() ? Dan
Re: [PHP] unset($_GET['i'])
Hi given page1 has a list of goods and sends $i as a variable into a link to page2, ie, a href=page2.php?i=3send/a Page2 adds the items recieved in an array. In page2 how can I unset the $_GET['i'] so that if I press F5(refresh) it doesn't add the same item to the array ? I tried unset($_GET['i']) but no success. Thanks How about just adding a simple counter on your page. if ($count == 0) { Run through your script At the end update the variable: $count == 1; } else { Don't run throught script because the value has already been added }
Re: [PHP] Google Chrome
Yippie, Chrome already exploited for DoS attacks? http://blogs.zdnet.com/security/?p=1847tag=nl.e539
Re: [PHP] unset($_GET['i'])
Dan Shirah a écrit : How about just adding a simple counter on your page. That's what I do but that counter resets when you press F5 and is not functionnal. Why $_GET['i'] doesn't unsets ? Are you saving the array to a database once it is created? If not, wouldn't the array be recreated once someone refreshes the page as well?
[PHP] Confused
All, Okay, I am a bit confused. I'm setting up another server to host PHP pages. I followed everything in the Manual for installing PHP. I'm running Windows Server 2003, IIS6.0 and PHP 5.2.6. And...it kind of works... If I do: ?php echo Test; ? it prints fine. If I do: Today is: ?php echo date(l, F j, Y); ? it prints fine. If I do: You are recognized as: ?php echo substr($_SERVER['AUTH_USER'], 13); ? I get no output. If I do: if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { // THE ACTUAL CONNECTION echo Unable to connect to Informix Database\n; // DISPLAY IF CONNECTION FAILS exit(); } I don't get a connection to the database and the Unable to connect to Informix Database\n; does not even display. I get no errors output to the screen and I have display_errors = On And I have error_reporting = E_ALL ~E_NOTICE Any ideas?
Re: [PHP] Confused
If it was that simple then the second line: echo Unable to connect to Informix Database\n; would execute upon the connection failing and that message would be output to my screen. I get Nothing. Just as a simple call to ?php echo substr($_SERVER['AUTH_USER'], 13); ? returns nothing as well. On 9/2/08, Simcha [EMAIL PROTECTED] wrote: This does not seem to be an installation problem - Your test [(!$connect_id = ] fails, since the connect returns false, so it does not run the condition. Compare: ?php if($a = false){echo no good;}else{echo condition true;} ? -Original Message- From: Dan Shirah [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 02, 2008 7:31 PM To: PHP List Subject: [PHP] Confused All, Okay, I am a bit confused. I'm setting up another server to host PHP pages. I followed everything in the Manual for installing PHP. I'm running Windows Server 2003, IIS6.0 and PHP 5.2.6. And...it kind of works... If I do: ?php echo Test; ? it prints fine. If I do: Today is: ?php echo date(l, F j, Y); ? it prints fine. If I do: You are recognized as: ?php echo substr($_SERVER['AUTH_USER'], 13); ? I get no output. If I do: if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { // THE ACTUAL CONNECTION echo Unable to connect to Informix Database\n; // DISPLAY IF CONNECTION FAILS exit(); } I don't get a connection to the database and the Unable to connect to Informix Database\n; does not even display. I get no errors output to the screen and I have display_errors = On And I have error_reporting = E_ALL ~E_NOTICE Any ideas? No virus found in this incoming message. Checked by AVG - http://www.avg.com Version: 8.0.169 / Virus Database: 270.6.14/1646 - Release Date: 02/09/2008 06:02
Re: [PHP] Confused
Add the following: ?php echo 'pre'.\n print_r( $_SERVER ); echo '/pre'.\n; ? See if the AUTH_USER entry is in there. AUTH_USER shows up, but does not have a value. From the output of phpinfo() it says, No value How do you know you don't get a connection to the database? What is the value of $connect_id? Use var_dump( $connect_id ) to find out. I know it isn't connecting because I can go to the database and see that there is no active connections to it.
Re: [PHP] Confused
So you're script runs long enough for you to check? Cheers, Rob. if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { Checks to see if it doesn't connect. If it does connect the page continues to process. If it doesn't connect the error is displayed. echo Unable to connect to Informix Database\n; If I put in the following: echo Point 1; if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { // THE ACTUAL CONNECTION echo Point 2; echo Unable to connect to Informix Database\n; // DISPLAY IF CONNECTION FAILS echo Point 3; exit(); } echo Point 4; The only thing that is output to my screen is Point 1
Re: [PHP] Confused
Your script is dying then. What does the error log say? Are you sure PHP is using the php.ini you think it's using? Double check by using phpinfo(). Cheers, Rob. It is VERY strange! phpinfo() shows that it is using C:\Windows\php.ini phpinfo() also shows display_errors = Off but when I go to the C:\Windows\php.ini file it says display_errors = On...
Re: [PHP] Confused
Does your script, the apache conf, virtual host conf, or a .htaccess conf modify this setting? perhaps php.ini has more than one display_errors entries? Cheers, Rob. PROGRESS! It just clicked! About 3 years ago when I setup my first PHP server on Windows I saw someone mention that certain versions of ntwdblib.dll were causing all kinds of problems. I copied the ntwdblib.dll from one of my current servers and now I am at least getting the connection errors! YAY! So now my connection error is probably in my ODBC mapping. But I still need to figure out why AUTH_USER is still No Value
Re: [PHP] Confused
Yea I thought the same that is why I recommended the looking at logs idea. Perhaps maybe just running form cli will do it: [EMAIL PROTECTED]:~/Sites$ php5 blah.php Point 1 Fatal error: Call to undefined function ifx_connect() in /home/eric/Sites/blah.php on line 3 You probably don't have extension=php_ifx.dll uncommented? Or you don't have php_ifx.dll in your ext folder?
Re: [PHP] Confused
[SOLVED] Just wanted to let you all know I resolved all my problems. AUTH_USER holds a value once I go into IIS/Default Website and go tot he properties of my application folder. Deselect the Anonymous Access and check Intergrated Windows Authentication. For my connection issue I needed version 2000.2.8.0 of the ntwdblib.dll file. The newer version causes issues and will not allow you to connect to an informix database. Thanks to everyone that helped. Dan
Re: [PHP] multiple question form creation
Hi, i have a web application in which some people should be able to create form adding questions and possible answers. basically user should: 1. type the question (which will be displayed to customer) 2. select type of answers (closed, open, list, multiple answer, and so on...) 3. add possible answers (could be several answers for 1 questions) what do i wonder it's how to do it in easy and nice way. I mean: 1. should i have 1 page asking for question title, 1 page for answer type and (for each possible answer) 1 page for each answer ? 2. should i have AJAX which will store data into session before storing into DB ? in this case it could be a 3 div content: 1 for question, 1 for new anwser type (a combobox for example) and 1 div for each new answer... but in this case how can i allow user to tell to system hey, i need to add another answer for this question ? i really would appreciate some help as it is not so hard to do it but to do it nice and well (userfriendly in fact) it is a little more complex. thanks a lot for your help. Alain, I would make everything on a single page. A text input for the Question Title A dropdown list for the different types A textarea for the answer section Then below the form just put two buttons: Finished which will save the last question and take them to your homepage Submit Another which will save the current question and then blank our the answer textarea You can use AJAX to make it seemless as far as the submission of data goes, or you could do ?php echo $_SERVER['PHP_SELF']; ? as your submit action.
[PHP] Search Suggestions
Hello, I'm hoping to get a few good ideas on the best way to perform a search of PHP results. Currently I have a page that returns a list of collapsed customer data: Example + John Smith + Jane Doe + Robert Jones + Dale Bennett If the user clicks on a customer name it will expand the selection: Example - John Smith - 123 Anywhere Street - myCity - myState - myZipcode - myWebsite + Jane Doe + Robert Jones + Dale Bennett Now, what my client wants is a Search functionality that will allow him to type in myState and have the application automatically expand and focus on the first match. Then, be able to click Next and have it collapse the first result and expand the next result that contains the same state. Any ideas? I was thinking that maybe I would have to create a temp table so it could be searched against, but I'm not sure if that is the best idea. Also, in order to save processing time, the way I made the above expanding/collapsing list is I don't not pull in the customer details intially but instead run a query and get the details when the name is clicked for expansion. This is because there could be potentially 1,000's of result and getting all of the names and all of the details at page load would 1) take longer than a user is willing to wait 2) exceed the timeout 3) exceed the memory allocation Thanks for any help/ideas. Dan
Re: [PHP] Assign things to users
Hi, This is more of a logic question than a PHP question. I wanted to get some opinions on how some of you are doing things like this. I have a set of employees in our quote management system. We get thousands of quotes per hour, and every 15 minutes I have a cron that goes out and grabs the unassigned and goes in a round robin fashion assigning the quotes to the employees. I have the table setup like: User ID, Username, AssignTolken What I've been doing is grabbing the user who has AssignTolken = 1, and giving them the next quote. Then I change them to 0, pull up the next user in line, and set them up to get the next quote with AssignTolken = 1. My question is: How do you all do handle similar situations like this? I've been thinking there has to be a better way to do it, but I have not been able to think of a good way to do it. I'd like to see how if I'm doing it like everyone else, or what else is out there. Any ideas would be appreciated! Dan, If what you're looking for is an evenly distributed workload, I don't see anything wrong with what you're already doing. However you might want to run a comparrison query every now and then to view the total number of outstanding requests assigned to your employees. Johnny and Susie might have both been assigned 1,250 qutoes today by your round robin method, but Susie is a much better worker than Johnny so her current outstanding quotes are at 50 but Johnny has 2,000 because he works slower. You might want to assign more quotes to Susie and reward her for being a good worker :)
[PHP] loop weirdness
Hello all! I'm having some weirdness with a loop. I am adding an conditional statement to my script to see if a condition is met before running a loop. All of the code up to this point works great so I have not included it since it is very long and extensive. Basically I have a query that runs and is output to $info. This is where the code below picks up. Whenever I add the if() I only get one result returned. But if I simply delete the if() statement I get all of the rows returned. Is there some weirdness where the closing backet of the if() statement gets interpretted by PHP to be the closing bracket of the while loop? print_r($row); does display all of the results from my query so I know they are in there. So the only thing I could think of is the curly braces being used for the while() before the if() ?php if ($f_date!=) { // Start of IF while ($row = ifx_fetch_row($info)) { // Start of While $case_date = $row['caa61140005']; $case_type = substr($row['caa38840002'], 4); $case_id = $row['caa443400018']; $case_num = TRIM($row['caa44340041']); $case_title = TRIM($row['caa44340002']); $case_category = TRIM($row['caa443400013']); print_r($row); } // End of IF ? tr td width='300' id=?php echo $case_num; ? height='13' align='center' class='tblcell'div align='left' id=?php echo $case_num; ?img src=Images/Next1.gifa href=javascript:caseDetail('?php echo $case_id; ?','?php echo $case_title; ?','?php echo $party_name; ?','?php echo $case_num; ?')?php echo $party_name.br /\n.$case_num; ?/a/div/td /tr ?php } //End of While ? Any ideas? Thanks, Dan
Re: [PHP] loop weirdness
Your comments indicate you're trying to end the if in the middle of the while, but what PHP will be doing is ending the while where you want to end the if. I assume what you actually want to do is end both after the HTML is output, but I'm just guessing. -Stut Depending on specific conditions, one of two queries will be ran. In one query $f_date == and in the other $f_date == some date If $f_date == some date then I will have multiple rows of data returned so I would need to use: while($row = ifx_fetch_row($info) { But, if $f_date == then only a single row would be returned and I would use: $row = ifx_fetch_row($info); So, depending if $f_date is or some date I have A LOT of tables and data that are populated with results pulled from the seperate queries and I don't want to duplicate all of that data.
Re: [PHP] loop weirdness
Perhaps I'm not understanding correctly, but you can still use the while loop if only a single row is returned, it'll just run the loop once. -Stut That's what I thought also and is how I had it setup at first! But for some strange reason it always returned 4 identical results instead of just one. I took the query and placed it in several SQL editors and all of them only gave me one result back so I decided to try a different approach.
Re: [PHP] Passing variable to a page in a frameset
I apologize for my ignorance, I don't really know much about javascript. When I add all that into my form page, when I submit the form, it just replaces the page I was on with the form results, rather than in the new frame page. I'm assuming I need to put the url for the frameset page in that code somewhere. Where does it go? And, which part do I replace with the frame name on that frameset page? Thank you for taking the time to help me with this, I really appreciate it! Let's look at the code: //var1 and var2 are the search criteria the user entered in your search form(You may have more or less) function submitForm(var1,var2) { //top.leftFrame is how you set the focus to the frame you want. leftFrame could be different on your system...whatever you named the frame. //top.leftFrame.document.my_search.text1.value=var1 assumes the form name in the frame you want data in is named //my_search and it givs the text object text1 the value of var1 from your search form top.leftFrame.document.my_search.text1.value = var1; //top.leftFrame.document.my_search.text2.value=var2 assumes the form name in the frame you want data in is named //my_search and it givs the text object text1 the value of var2 from your search form top.leftFrame.document.my_search.text2.value = var2; //top.leftFrame.document.my_search.submit() will submit the form in your target frame then you can use the $_POST values throughout the frame top.leftFrame.document.my_search.submit(); //document.search_form.submit() will submit your search page. I use this so I can reuse the $_POST values to display the search criteria after submit. document.search_form.submit(); }
Re: [PHP] Displaying files
If the network resource is the only location where these files exist, what do you suggest I do? Use PHP to first copy() the file from the server to a temp directory on my web server and then open the document from the temp dir? On 8/14/08, Boyd, Todd M. [EMAIL PROTECTED] wrote: -Original Message- From: Stut [mailto:[EMAIL PROTECTED] Sent: Thursday, August 14, 2008 4:34 PM To: Boyd, Todd M. Cc: php-general@lists.php.net Subject: Re: [PHP] Displaying files On 14 Aug 2008, at 22:24, Boyd, Todd M. wrote: -Original Message- From: Stut [mailto:[EMAIL PROTECTED] Sent: Thursday, August 14, 2008 4:21 PM To: Dan Shirah Cc: PHP-General List Subject: Re: [PHP] Displaying files On 14 Aug 2008, at 21:57, Dan Shirah wrote: That simply means it can't open the file. Make sure the machine this is running on has everything it needs to access that UNC filename. -Stut Stut, If I copy the link from the error message and paste it into a browser running from my PHP server, the file comes up just fine. Should I try mkdir() or mkpath() to set the server and folder location and then try it from there? The user PHP runs as needs to be able to access it, not you. I'm guessing you're on Windows... If you're using IIS then it's the IUSR_machine user which doesn't have access to the network by default. You can enable it but I can't recall how off the top of my head and you may want to reconsider because it leaves the server a lot more open should IIS/PHP/else be compromised. If you're using Apache on Windows then you'll need to check the service configuration to see what user it's running as. It can be done somewhat securely by mapping a network drive and then granting permissions to it specifically, rather than the network itself. (I believe...) It's been a while since I've used Windows but IIRC you need to enable network access for that user at the lowest layer (i.e. system policy) and then normal access rules apply, but I could be wrong. Either way I'd avoid doing it if at all possible. I think after XP SP2 it got a bit more granular. However, I'm no MCSE, so don't take my word for it. :) I do agree with you, anyway, that the user a webserver is posing as should not have access to network resources like this. I digress. Todd Boyd Web Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Displaying files
Okay, I'm perplexed! If I put the exact same value into a javascript function and open a window the document comes up perfectly fine. But, when trying to readfile() copy() or fopen() in PHP I get the failed to open stream: error. Any idea why the exact same link would open fine using a HTML link or a javascript function, but will not work using PHP?
Re: [PHP] Displaying files
Because as I mentioned before PHP runs as a different user to your browser. -Stut Stut, Are you referring to this? If you're using IIS then it's the IUSR_machine user which doesn't have access to the network by default The IUSR_SERVERNAME account is what it should be connecting as whether I'm using PHP/Javascript/HTML, unless specifically set in a connection string such as the database connections. But, the initial calls always come from IUSR_SERVERNAME. Thiago, HTML WORKS a href=\\server\folder\file.xls target=_blankOpen/a Javascript WORKS function openWin(folder,file) { var LeftPosition = (this.screen.width) / 2; var TopPosition = (this.screen.height) - this.screen.height; var Height = (this.screen.height) - 90; var Width = (this.screen.width) /2 - 10; MyWin = window.open(server\\+folder+\\+file+\.xls,ViewImage,scrollbars=yes, status=yes, resizable=no,top=+TopPosition+,left=+LeftPosition+,width=+Width+,height=+Height+); MyWin.focus(); } PHP DOESN'T WORK $filename = server\\.$folder.\\.$file..xls; header(Content-Type: application/x-msdownload); readfile($filename); I put all three of these examples into the exact same page. The HTML and Javascript open the file without any problems, but PHP cannot open it.
Re: [PHP] Displaying files
Wow, I think it finally clicked. Sorry that took so long. The whole point behind using PHP was to try and copy or call the file from the server side so the user does not see the path to the document. Using HTML and Javascript it is extrememly easy to just view source and see the path. Whereas using PHP it would take the regular user a bit more work to view the path which is why I wanted to go that route. But having to grant the anonymous internet account access to the server would be just as bad if not worse. My application retrieves a list of docments that the user can view based on search criteria. When the user clicks on the document I wanted to somehow mask the location the document is being pulled from. HTML and Javascript are so easy to circumvent, even to the everyday user that I wanted to do something with PHP since it's code is not viewable when you view source since it is run on the server. Have any of you attempted something like this?
Re: [PHP] Displaying files
What about using some type of a dispatch script? Locate all the files outside of the doc root and then just call: viewdocument.php?ID=12345678 ? Although now that I've typed that I realize that you would still be running the same issue.. Unless you used javascript in your PHP to call the file maybe? Hmmm, what if I tried to use PHP to write a simple batch file? Use the batch file to copy the selected file from one server to another. And then open the copied file using any method I wanted since it's new location would be in a temp directory? And then maybe use if_exists() to see if the new file is located in the temp directory and if it is, display it. The only issue there might be when a file is really large or the network is sluggish and it could take 1-5 seconds for the file to copy over. In which case if_exists() would be false since it is taking a while for the file to copy. Hmmm.
Re: [PHP] Re: Passing variable to a page in a frameset
Frames?! As a fellow Wisconsinite and a web developer, I'm going to have to ask you to leave the state. Minnesota can have you. :P Jay PS - No, but seriously, frames?!?! There's nothing wrong with a Frame every once in a while! Granted they aren't used much anymore, but sometimes they can be useful!
Re: [PHP] Displaying files
Your best bet would be to run a periodic sync to copy the files across from the other server but it would have to run outside the IIS process. There are plenty of solutions around for doing this and they have nothing to do with PHP. You can then refer to the local copy of the file from PHP and it will then work. This isn't very feasible because the server that contains the documents contains almost 1 terabyte worth of documents and continues to grow in size. No way I would want to mirror that amount of information just to hude the file path. Instead of just making and executing a batch file, maybe there is a way for PHP to call a scheduled task? Since within a scheduled task you specify what username/password is used to execute it I may be able to get it to work?
Re: [PHP] Displaying files
A scheduled task is messy. IIWY I'd use FTP to pull the file over, but that's still pretty messy. If this is an Intranet then the risks involved in giving that user access to the network is minimal and probably would be the best solution. Alternatively you could set up an HTTP server on the document server and proxy the documents through the IIS server (readfile should be happy to take an HTTP URL unless you've disabled it in php.ini, and the end user will never see the actual URL). I agree, it is really messy to work with and prone to lots of complications. This application will be used within our network, but will also be used by a sister agency that is not in our network. Which is why we do not want the document server complete path floating inbetween us and them where it could be intercepted by an outside user. Reading the documents through as a URL would be so nice and probably the easiest method to accomplish this, but the God's Above want it to remain strictly a file server. I guess I will start looking into FTP'ing them between servers as that may be the simplest solution at this point.
Re: [PHP] Passing variable to a page in a frameset
In the head of my page, I have this: script type=text/javascript function submitForm(var1,var2) { top.mainFrame.document.my_search.text1.value = var1; top.mainFrame.document.my_search.text2.value = var2; top.mainFrame.document.my_search.submit(); document.search_form.submit(); } /script If I type in a word in the search box http://beta.menashalibrary.org/about and hit enter, it searches the catalog just fine, but then just replaces the current page with the search results. If I click on the SEARCH link with the javascript, it does nothing. It looks like you haven't adapted the example I gave you to conform to your page/form structure. top.mainFrame.document.my_search.text1.value = var1; The frame you are populating may not be named mainFrame The form in your destination frame may not be named my_search The input in you destination frame may not be text1 You have to modify these areas to suit your application and add or remove more as needed.
Re: [PHP] Passing variable to a page in a frameset
So, I had this all wrong before. Basically, I need two forms, right? One on my originating page, and one on the page within the frameset I want to pass the values to. Correct? My form, which I named my_search has one input field, which I named query. In the javascript, I put in this: script type=text/javascript function submitForm(var1,var2) { top.mainFrame.document.my_search.query.value = var1; top.mainFrame.document.my_search.submit(); document.search_form.submit(); } /script In the framset named mainFrame, I have a page which matches the form on the originating page. Am I on the right track? When I click on the search link, nothing happens. mainFrame should not be the name of your frameset. Say I have a frameset with three sections. Top, Left, and Right...you will actually have 4 pages. Frameset.php //The top level of the frameset that doesn't do much more than assign the Frame names and pages associated with them TopSection.php //Anything on this page will be displayed in your top frame LeftSection.php // Anything on this page will be displayed in your left frame RightSection.php //Anything on this page will be displayed in your right frame In order to see the names assigned to your different frames you need to open Frameset.php and look for them. It will look something like this: frameset rows=200,* cols=* framespacing=0 frameborder=NO border=1 frame src=TopSection.php name=topFrame scrolling=NO noresize frame src=LeftSection.php name=leftFrame frame src=RightSection.php name=rightFrame /frameset You should never need to reference Framset.php directly. Say I wanted to pass a value from TopSection.php to a text field in LeftSection.php I would do this: TopSection.php form name=search_form method=post action=?php echo $_SERVER['PHP_SELF']; ? input type=text name=search_name value= //The default value will be blank but will change if someone enters in text. /form //Now the persons submits the form and you want the search name to populate to your other frame. a href=javascript:submitForm(document.search_form.search_name.value)SEARCH/a //The Javascript function this calls will pass the document.search_form.search_name.value to the new form function submitForm(name) { top.leftFrame.document.my_search.search_name.value = name; document.search_form.submit(); } //top goes to the highest level of your frameset, leftFrame is the frame name specified for LeftSection.php on your Frameset.php page, document.my_search is the name of your form in //LeftSection.php, search_name is the name of your text field within the form in LeftSection.php //Your TopSection.php form has now passed the search_name value to the LeftSection.php page LeftSection.php form name=my_search method=post action= input type=text name=search_name value= /form That should be enough to get you going. If you have any further questions lets take this Off List since it does not relate to PHP. Dan
Re: [PHP] Re: Passing variable to a page in a frameset
That is exactly what I want. I apologize for the confusion. I was having a hard time trying to put what I was trying to do in words. But, yes, your second paragraph is exactly what I want to do. My knowledge of PHP is very limited, and I've tried to search for something that will do this, but couldn't find anything. - jody In that case, I would not use frames at all. I believe in the top frame all you wanted to store was the search text, right? Just have your search link do something like this: html head script language=JavaScript !-- function submitForm() { document.search_form.action=' http://beta.menashalibrary.org/sites/beta.menashalibrary.org/themes/salamander/searchframe.html '; document.search_form.submit(); } //-- /script /head body form name=search_form method=post action= input type=text name=search_name value= a href=javascript:submitForm()SEARCH/a /form /body /html And then on http://beta.menashalibrary.org/sites/beta.menashalibrary.org/themes/salamander/searchframe.html just assign your posted search value and make a hidden form field. html head body ?php $searched_text = $_POST['search_name']; ? form name=my_search method=post action= input type=hidden name=search_text value=$searched_text table width='800' border='0' align='center' cellpadding='2' cellspacing='2' bordercolor='#00' tr td?php echo You searched for: .$searched_text; ?/td /tr /table /form /body /html
Re: [PHP] Re: Passing variable to a page in a frameset
I work for a consortium of 30 libraries. Each library has their own website, but they all share the same web catalog. On each library's website there is a search box to search the catalog, which is on a completely different server from the websites. We've been finding that once people use that search box, they get distracted with the catalog and have no easy way to get back to the library's website. The problem I was tasked with is, coming up with a way to search the catalog with an easy way to return to where the user was before they initiated the search. The only way I thought to do this was to use a frameset for the search results. Which, you can see here: http://beta.menashalibrary.org/sites/beta.menashalibrary.org/themes/salamander/searchframe.html If anyone has any ideas, other than using frames for the results, I'd love to hear them. The problem is, there's nothing I can do on the web catalog end. - jody Easiest solution - Open the search page in a new window. Then they can just close it to get back to the previous window... I now understand what you're trying to say in regards to the frames. The top frame resides completely on your server so you can place a Go back to homepage link to direct people back to YOUR libraries homepage. And the bottom frame contains the search results page that you have no control over and cannot alter to simply place a Home link on it. And that should remain since the global search results page is accessed by multiple libraries. Like I said above, the easiest thing to do is just open it in a seperate window so they can close it at any time and still be at the same place on your libraries website.
Re: [PHP] Re: Passing variable to a page in a frameset
GET should work too. Do you know of any examples anywhere online for this? My brain shuts off at the thought of how I'd do that. - jody When you GET a value you are retrieving a passed value that appears in the address bar: Example http://www.mysite.com?name=joe www.mysite.com is the website ?name=joe is the value being passed by GET To put this value into a PHP variable you would simply do: ?php $name = $_GET['name']; ? http://www.google.com/search?hl=enq=encrypt+javascript
Re: [PHP] Re: Passing variable to a page in a frameset
On 8/15/08, Dan Shirah [EMAIL PROTECTED] wrote: GET should work too. Do you know of any examples anywhere online for this? My brain shuts off at the thought of how I'd do that. - jody When you GET a value you are retrieving a passed value that appears in the address bar: Example http://www.mysite.com?name=joe http://www.mysite.com/?name=joe www.mysite.com is the website ?name=joe is the value being passed by GET To put this value into a PHP variable you would simply do: ?php $name = $_GET['name']; ? Although, since you have no control over the actual search page to edit the code and have it pull in the $_GET[''] values you will probably have to disect the search page to get its form elements so you can feed them to it and force a submit. I just looked at your site, and after I input my search criteria and click submit I have to again enter in the search criteria and submit to actually get some results.
Re: [PHP] Re: Passing variable to a page in a frameset
There you go! Entering in the search criteria pulls up the search in a new window and automatically pulls results based on your search. Then I can just close the window to return to where I was on your site. I think that is simple and easy to use. And I'm sure not much of a headache for you!
[PHP] Displaying files
I think this should be a simple question and answer, but after looking through the manual and goggling I have yet to find an answer. Question: Using PHP, how would I go about opening a file in a window, table or div? Example: I have a file called 123.xls. When a condition is met, I want PHP to open this file into the current window. I know I can use Javascript to easily do this, but due to the requirements of my application, javascript is not an option here. I tried using fopen() but that only opens the file in the background for PHP to read/write to and will not display the file in a browser. Any ideas? Thx, Dan
Re: [PHP] Displaying files
Who needs PHP... :) The following will open a new browser window and load the href in it. a href=http://examples.com/123.xls; target=_blankOpen It!!!/a If that isn't what you are looking for, please give a little more details. You're killin' me, Jim! :) I need to open the file from the server, using PHP. I already know how to open it using HTML and Javascript, but those methods cannot be used for this section of my application. I need to call and open the document in the browser window using PHP. Example: If I was going to do it with Javascript I would just use something simple like this; function open() { window.open('open.php'); } Or, if I was going to use HTML I would use something simlar to what you posted. How can I achieve that same functionality using only PHP? Or is it not possible?
Re: [PHP] Displaying files
You need to know the mime type for the file you're serving. Call header('Content-Type: x/y'); where x/y is the mime type. Then call readfile('/path/to/file/on/server'); to output the file to the browser. -Stut Stut, trying that method gives me the following: PHP Warning: readfile( \\server\folder\file.xls) [a href='function.readfile'function.readfile/a]: failed to open stream: Invalid argument on line 44 Here's my code. Line 44 is where it stated readfile() This document is located on a seperate server. ?php $folder = $_GET['folder']; $file = $_GET['file']; $filename = server\\.$folder.\\.$file..xls; header(Content-Type: application/x-msdownload); readfile($filename); ?
Re: [PHP] Passing variable to a page in a frameset
Hello, I've got a website here: http://beta.menashalibrary.org/about On every page, i've got a search box at the top. This search box searches the library's web catalog. The problem is, when someone searches, it takes them away from the site. What I'd like to do is take what a person searches for, and load it into the bottom frame of this page: http://beta.menashalibrary.org/sites/beta.menashalibrary.org/themes/salamander/searchframe.html Is there a way, with php, to take what someone puts in the search box and put the results into the bottom frame of a frameset when the originating page does not contain frames? - jody Bastien is right, this is more of a Javascript issue. It can be accomplished very easily by doing the following. Once the user enters the search criteria have the submit button/link call a javascript function like the following: function submitForm(var1,var2) { top.leftFrame.document.my_search.text1.value = var1; top.leftFrame.document.my_search.text2.value = var2; top.leftFrame.document.my_search.submit(); document.search_form.submit(); } And this would be your submit link: a href=javascript:submitForm(document.search_form.var1.value,document.search_form.var2.value)SEARCH/a