Error Using Header("", FALSE) To Show Multiple Images From MySQL Db
Many people seems to have problems when displaying multiple images from their database (mySQL db). Often you can read error statements like "Header already sent out ...". To solve this, people often propose to use include files.
To keep the scipt it would be nice not having this problem, being able to sent out multiple headers to a browser without getting these error messages. In the PHP4 manual, we can read an option that can be added to the header statement, Header("xxx",FALSE). It would enable multiple headers to be sent out.
For instance the following statement:
while ($product = db_fetch_object($result)) { header("Content-type: pv($product->filetype)",false); echo pv($product->image)" }
However, it doesn't work. Anybody has any idea why? Does anybody use this option FALSE with success?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
'Parse Error' Problem In "isset" And "empty"
I've been having some problems with a parse error that I can't figure out (PHP 4.3.11 on Solaris9). Sample code: <?php // getting strange parse errors on this class A { var $value; function A() { $this->value = 1; } function getValue() { return $this->value; } } $a = new A(); if (!empty($a->getValue())) { echo "success"; } else { echo "failure"; } ?> The result of this is: Parse error: parse error, unexpected '(', expecting ')' in /foo/public_html/parse_errors.php on line 15 I also get the same effect with "isset", however, testing with "is_null" or "is_int" produces the correct ("success"/"failure") result. Any ideas?
Please Help: "header Already Sent" Error
How can I produce an output to the browser and let the script continue to work in the background, producing a later screen output? Example: Trigger a database search so that the user immediately sees a "...searching..." screen while the script actually searches and later on outputs the result. I always get a "header already sent" error.
Error In Page When Checking Http_get_vars("myvar") And "myvar" Was Not Passed In URL String
PHP, coming from ASP coding if (HTTP_GET_VARS['b']==1){ print "Yes"; }else{ print "No"; } when "b" is not passed via (http://www.mydomain.com?b=1 an error occurs and the "NO" is printed but an error is printed too. How can I check for the value of "b" so that no error occurs if b is not passed?? example http=www.mydomain.com $myvar=HTTP_GET_VARS['b'] causes an error because "b" does not exist (ie. its not passed in the URL string. $myvar maybe evaluated as NULL or Empty but the error is printed in the page, anyway.
Problem With "escaped Characters" Not All Double Quotes Show Up?
$tdsubclass=<<<bumelum <td><a href="http://www.ygabel.php/$artnr[$arayartnrcounter]" ="" onmouseout=" function onmouseout(event) { window.status = "Done"; return true; } " onmouseover=" function onmouseover(event) { window.status = "http://www.fup.dk"; return true; } "> <!--target="_Self"--> bumelum; When I print this the double quotes after Done" and after dk" are missing? I have also tried with escaped characters in double quotes
Why Does The Word "Array" Show On A Select Query
I am new to php and MySQL and I'm attempting to run a select query on a MySQL database which is working fine except prior to displaying the table with the results from the select query it displays 1 line for each row in the database containing only the word Array. This is then followed by the correct results in the constructed table. I am not storing the string "Array" in my table. Following is the PHP code for constructing the table from the results variable. for ($i = 0; $i < mysql_num_rows($result); $i++) { echo "<tr>"; echo $row = mysql_fetch_row($result); for ($j = 0; $j < mysql_num_fields($result); $j++) { echo("<td>" . $row[$j] . "</td>"); } echo "</tr>"; } I hope this is enough of the PHP script to solve the problem
Show Pictures With Correct Filename, Else "No Picture"
I want this script to get the pictures with the id of persons in a database, this works. But when there are no picture with correct id in the folder I want the script to show a "No picture"-picture, but this doesn´t work with this script. Why not? Code:
Mysql_query("show Status") To Get Info
to check the total amount of data written into the database by performing a script i did this way: <?PHP $info=mysql_query("show status"); $write=mysql_result($info,3) ( 3 or 4 or whatever dosnt matter ) my code here $info2=mysql_query("show status"); $write2=mysql_result($info,3) ( 3 or 4 or whatever dosnt matter ) $byte_written=$write2-$write1;>? it works, but the script runs extremely slow do you know another way to take this info ?
How Do I Do Something Like $color = ("red", "yellow", "blue")[$colornum]?
How do I take an index of a literal array, instead of a variable? That is, say I want to get the short name of a month. Can I do something like: $monthname = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")[$month]; or do I always have to do: $blah = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); $monthname = $blah[$month]; It seems a shame to have to create a variable specifically for this one-shot purpose.
Mysql/php - "LIMIT" And "ORDER"
In the following fragment of code, I am querying a database that in order to display a list of films. The list is very long and I would like to offer the possbility to restrain the range of results showned by page keeping in mind that the user should be able to browse forward or backward data if applicable. I know that I have to add the LIMIT method in the MySQL query but I have a hard time figuring how not to get lost in setting it dynamically in the PHP script. Then I have a second question. Is there a more elegant / straightforward way to deal with the display order of the data (cf. $ot, $od and $oy)? Code:
Sticking "if" Or Changes Within A MySQL "where" Array?
I'm not exactly sure how to even ask the question, and I know my terminology is not good as I'm a SQL beginner, but, here goes. I need to find a way to make an if statement within an array...or, the "while" portion of a recordset. The best way I can ask is show what I mean. http://oscarguy.mechphisto.net/awardbrowse.php If you go there and select an award (like Best Picture), leave the year field alone, and select YES and submit, you'll see a lot of results. And I have HR's dividing each entry. What I need to do is group all the entries of the same year, or at least only put HR's between the blocks of years. So, I'd have all the entries for 2002, an HR, then all for 2001, an HR, etc. Here at the bottom I'll include my PHP code I'm using so far. But I have no idea where to even start looking for an answer...if it's even possible. If someone can just give me the name of the function or process or technique, then I can go Web/book searching myself...I just need a direction of where to go. PHP:------------------------------------------------------------------------ ------ $query_RS_award = "SELECT * FROM $award WHERE id != Ƈ' ORDER BY year DESC, w DESC"; //$query_RS_award = "SELECT * FROM $award WHERE year = "$year""; $RS_award = @mysql_query($query_RS_award, $connection) or die("Couldn't query: " . mysql_error()); $totalRows_RS1 = mysql_num_rows($RS_award); while ($row_RS_award = mysql_fetch_assoc($RS_award)) { $award_id = $row_RS_award['id']; $award_tblid = $row_RS_award['tblid']; $award_award = $row_RS_award['award']; $award_year = $row_RS_award['year']; $award_category = $row_RS_award['category']; $award_won = $row_RS_award['w']; $award_film = $row_RS_award['film']; $award_nominee = $row_RS_award['nominee']; $award_note = $row_RS_award['note']; if (!($award_category)) { $award_category = "n/a"; } else { $award_category = $award_category; } if ($award_won == "1") { $award_won = " - Award Winner"; } else { $award_won = ""; } $display_block_Award .= "YEAR: <span class='normalText12White'>$award_year</span><br>FILM: <span class='normalText12White'>$award_film</span><br>CATEGORY: <span class='normalText12White'>$award_category</span><br>NOMINEE: <span class='normalText12White'>$award_nominee</span><span class='normalText12BoldWhite'>$award_won</span><br><blockquote><span class='normalText12White'>$award_note</span></blockquote><hr>"; }
"Cannot Modify Header Information" With Large HTML FORM Options
I'm having some really odd behavior with a PHP script. I have it populating an HTML select form with a for loop. When I try the years 2006 to 1900. I get the following error: PHP Warning: Cannot modify header information - headers already sent by (output started at /Users/chrobb/Sites/city-directory/controlBar.php:54) in /Users/chrobb/Sites/city-directory/controlBar.php on line 88 I've done a fair amount of searching and it looks like this usually shows up when people have some extra whitespace after their closing PHP tags. Doesn't apply seem to apply here. When I crank the number down on the for loop to 94 iterations, the error goes away. Once I crank it up to 95, the error comes into play. So, it's tied to the output somehow. Looking at the raw HTML, there doesn't appear to be any significant difference between the version with 94 iterations versus the one with 95 iterations, except for the error and the failure of my script.
Aren't Session Variable Preserved Using "Header('Location: Xxx')"?
I am trying to pass some info to another page on my site. I set "session_start()" in page 1, assign a session variable to a value, then execute a "header('Location: ....')." But on the target page I don't get any session variable values! BTW, I used a relative location in the Location header, not an absolute URL. The behavior looks like it started another session, but it should not have.
@header("Location: $HTTP_REFERER"); Not Working In Bedford
I have a weird problem. I have an add to cart link on a page which calls a page called AddCart.php with item ID as parameter. This page adds things to the database and then calls @header("Location: $HTTP_REFERER"); It works fine everywhere as far as I know, yet 2 people from Bedford, UK, have told me within 3 days that when they click on add to cart they get the IE standard 'Page unavailable' page. I have been over their IE configuration with one of them and it is configured exactly the same as me, where it works fine. Has anybody got an idea please?
"header" Call Doesn't Work Before Lenghty Operation
My config: Win XP (or 2003), Apache 2.0.54, PHP 5.1.2. I have been trying to handle the case of a lenghty opearation on the server while providing the user with feedback and ability to cancel, and nothing seems to work so far. The following code is one attempt to address this, and it is called as result of a POST: //*************start code*************** session_start; // prepare exec // flush session data session_write_close; // trying to display a "Please wait..." message: header( "Location: please_wait.php" ); // long exec exec( ... ); // finally show the result of the exec header( "Location: exec_result.php" ); //************end code*******************
Header("Cache-Control: Public") Not Working
I have read somewhere else in this newsgroup that the way to avoid the message (Warning: Page has Expired blah, blah blah ... ) when one presses the back button is to place the statement header("Cache-Control: public"); at the top of the script. I have done this but I still get the annoying message. The session.cache_expire in php.ini is set to 180. I am using shared SSL.
Client-side Function To Resize ".jpg" Images
Does anyone know where I can find a client-side function I can reference from within an HTML/JavaScript web page? I'm currently using the core "imagecopyresampled()" PHP function to do this, but I'd rather do it on the client-side and not have to upload the large raw image to the server.
Looking For POST Equiv In Header("Location: Xxx")
I'm trying not to display the parameters being passed by: print Header("Location: http://www.bytedesigns.com?License=$license&expdate=$expdate"); If I use a form with method=post, no values are shown. The header() in my example behaves like an html method=get, i.e. values displayed on the URL. Any hints, suggestions and/or pointers to websites that might be able to help me to not display the parameters added will be greatly appreciated.
How To Do A Redirect To A "_new" Window With Header()?
I have an app that generates PDF reports using the FPDF class from www.fpdf.org. I use a PHP header() redirect to pass all the form variables (after error checking and processing them) to my report generator program. This works great as long as Adobe Acrobat does not load itself as a plug-in into the browser window forcing you to click the back-arrow to get back to the Web app (forcing a second post). Two options: (1) Find a way to force a download of the PDF so it is processed by Acrobat seperate from the browser (ideal), or (2) Generate another page (like target="_new") to house the PDF. I could not determine for sure if a newpage could be generated in a header() statement by the PHP docs. Is this possible? If not, how would I accomplish this? (inline Javascript maybe?).
Redirect Scripts And Header ("Location: ...")
I made a little redirect script but am getting a 'headers already sent' error on the line with the 'header ("Location: http://someotherdomain.xx")' command. It doesn't make any sense to me why that is happening, since it should send the user to a different domain. Of course the headers are already sent for the page myredirectscript.php, but not for the page on the other domain ....
Sending "header" Info After HTML?
I am looking to use "header("Location:index.php");" in my code. Basically this will be called when the user logs in to redirect them to the home page but as you expect I get the usual "headers already sent message" Just wondering how to get around this? Do I use the ob_start() method or something?
STRANGE "Fatal Error: Call To Undefined Function..." ERROR
why strange you ask? here goes: I have been working with Php and Mysql for a week without any problems. Today I tried executing a php page that connects to mysql and creates a new database, I got this error: "Fatal error: Call to undefined function mysql_connect() in C:Program FilesApache GroupApache2 est\_debug_tmp.php on line 3". I did some reading on the net and checked all my configuration, and it looks o.k. (and it already worked well a whole week before today). The strange thing is that I have another form that inserts data into the same database in Mysql, and it works like a charm (needless to say but both pages log in with the same username to the same database).
Size Of "images" Created By Imagestring
imagestring essentially turns text strings into images. Unfortunately, these images can be of any size and, as far as I know, an images size needs to be decided upon before imagestring is called. So is there anyway the size that imagestring would require could be calculated before the image was created?
Preventing Visitors Ability To "re-visit" A Page Via The "back Button"..
I have a rather complex registration/member sign up form.. which gets a little confused, when a visitor "backs" completely out of the form, then for whatever reason returns to the form. The form contains 'cancel' buttons, which naturally cancel the reg process and redirects them to the document just before they started. JS provides us with the "location.replace()" method, but I can't seem to find a way to coordinate the use of location.replace() with the posting of the form values. In short, I want to "replace" the first step of the form with the "second step". I think what's making this tricky, is that each step of the form are located within the "same" page (register.php). The document works like so: The first step is the "Member Agreement" when they click "agree" (submit) the system creates a new row in the temporary register table of the db. It then issues a registration cookie, which carries the row id, and session value. in addition (for those cookie impared users) we carry the row id and session value in hidden elements. So far, as long as the user continues through the process all is fine, but if they (for whatever reason) back all the way out, and click 'agree' again, the process fails. I guess I have to find a way to force a reload of the 1st step "if they've gone back" OR "replace()" the first step with the second, so as to prevent the user from going "back" to the 1st step of the register page.
Header("Location: Url"); In Mailer
I've tried putting Header("Location: http://myhost.com/me/page.html"); in my mailer's top, middle, even bottom...and it's never worked. All I'm able to do is call on a file...not a page. I really need a html page that has my thank you and tell-a-friend on it.
Header ("Connection: Close")
Relating to a post in this thread, does anyone know if there is there any practical different between: <?PHP Header("Location: http://www.example.com/widget.html"); Header("Connection: close"); ?> and: <?PHP Header("Location: http://www.example.com/widget.html"); exit; ?> From a (very) quick browse it seems that the exit command will generate a "Connection: close" header by default. Does "Connection: close" have the same effect as exit in that no further PHP code on the page will be parsed?
[PHP 5 XP IE6]header("test"); Does Not Display
I'm trying a simple form.html that call a .html script that begins with: <?php header("This is a test"); ?> When I click on the link, I get blank page. I tried every combination of .html and .php as extensions, none works. I checked the >Tools>Config>advanced menus in IE6, I can't find where could be some filter to prevent the headers from displaying.
Header("Location: ..."); Problem
I get the following message when trying to run my script: "Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/newcustomer.php:23) in /var/www/html/newcustomer.php on line 332" ....newcustomer.php:23 is where my script begins, at line 23. before that line, only comments. The script recives data from a form, checks if the customer exists, if so, it updates the data otherwise inserts a new customer into the db. Also some validation is done before writing to the db. FM> And here's the flow of my script: <?php include 'db.inc' include 'error.inc. //init error string $errorString = ""; //clean & trim POSTed values ... ... ... //validate data if (empty($formvars["source"])) $errorString .= " <br>You must suply the name of the source."; //validate other data ... ... ... //end of validation //check if errors exist if (!empty($errorString)) { //errors do exist, show them & exit ?> <html> <body> <br>Errors were found. <br> <?=$errorString?> </body> </html> <?php exit; } //if all data valid, open connection and load into the db if (!(connection = @ .....)) die( ... ); if (!mysql_select_db( ... , ... )) showerror(); //Are the data being updated? Then update the database if (!empty($cust_id)) { $query = "UPDATE customer SET " . "source = "" . $formvars["source"] . "", " . ... ... ... ... ... ... WHERE cust_id =$cust_id"; } else //Create query to insert the data $query = INSERT INTO customer ... ... ..."; //Run the query on the customer table ... ... ... //Is this an insert? if (empty($cust_id)) //find the cust_id of the new customer $cust_id = mysql_insert_id(); //Now redirect the customer to the receipt page header ("Location: cust_receipt.php?cust_id=$cust_id"); ?>
Redirect -- Header("Location:")
When I use the header redirect I get this error. I have heard there is trouble w/ this function in IIS, but works fine w/Apache. Warning: Cannot add header information - headers already sent by (output started at include.php:1)
Header("Location:") Substitute ?
Is there something else than "header(Location:)" one could use to redirect users to another page? I get the "Cannot add header information - headers already sent...." message when I try that. I'm using a main page that includes "subpages" in it. And I want to redirect users from one of the "subpages". In ASP you could use "server.transfer" and "response.redirect" where ever you wanted! But I don't like ASP anymore so.... ?
Header("Location: ..."); NOT WORKING!?
I'm working on a very simple peace of php where basically there is a form and 3 buttoms. One refreshed the page, one posts the form, and another one (since this form contains values of a record) deletes the record. The sintax is this one: if ($delete) {header ("Location: $redirect?del=$code&table=$tab"); exit; } where $delete is the buttom, $redirect is the string containing the url ("http://www...."). $code and $tab are values verified and correct. Well the funny thing is that this line worked well since I add the third buttom (the delete) after I added it even the post buttom doesn't work anymore. Exactly the page refreshes itself wihout changing parameters ($redirect contains in fact the same page but with different parameters) and stops loading the page after this line (probabily the exit() kicking in). Is there another way to redirect a page other then header()??? It's driving me crazy...
$PHP_SELF + Header("Location:");
Is it possible to user $PHP_SELF and then in if($_POST) can i use header("Location:"blah.php); as i really cant get it to work Code:
Mail(); "filename" Header?
What header is used the set the filename? Right now, when sending an html email, the attached file is named "unnamed". Here are the headers I am currently using: //Headers $headers = 'MIME-Version: 1.0' . " "; $headers .= 'Content-type: text/html; charset=iso-8859-1' . " "; $headers .= 'From: ' . $email; I did a brief google search which did return results, but piecing it together didn't work out so well.
"header(Location:" Not Working
The below code does not redirect: does anyone know why? if ($_SESSION['prevpage']) { #echo "session"; header("Location: http://localhost/index.php"); exit; }
Pagnation - Limit Number Of Pages Between "Previous" & "Next" Hyperlinks
Was hoping for some advice with a part of page navigation.... It works at the moment so there is a "Previous" & "Next" Hyperlink underneath the records. In between the Previous & Next links are the number of pages that there is of these records. e.g: Previous 1234 Next This is fine if there are only a few pages of records, but when there are hundreds of pages the numbers are listed and they take up half the web page with them. How can i make it so only limited 10 numbers of pages say appear between the "Previous" & "Next" Hyperlink and as you progress through the pages they are as do the next 10 numbers of pages? Code:
[regex] Stripping Out "name" And "value" Values Out Of Tags, Aaargh
Searched through the site, but couldn't find the right regex syntax I was looking for. the thing i want is, to extract with preg_match_all the given values in a tag... ex. $str = '<input type="text" name="name" value="value">' $pattern = some magic stuff I need to know preg_match_all($pattern, $str, $result); And in result I want to have the values text, name and value AND it's important that the order doesn't matter so structure of tags can be <input type =name= value=> or <input name= class= value= type=> etc, etc...
Forms :: The "select Multiple" Is Evil
I'm writing a form with a "select" window called "choices" and when I send the form data to the next page, I end up with the last value selected in "choices." I know that multiple selects are stored as arrays, but my problem is that PHP is only showing the last array element. Ideas? Here's the basic form code: ... <form name="list" action="./print.php3" method=get > <select name='choices' multiple size=10> <option>hi</option> <option>there</option> <option>dude</option> </select> <input type=submit> </form> ...
Problem With <select Multiple="true">
I have a form with a select element with multiple="true". When using the GET method (I suppose the same happens with the POST method) I can seen that the form sends channels=CH1&channels=CH2 when CH1 and CH2 have been choosen. $_GET["channels"] gives me "CH2". Is there any way to get all the choosen channels elements? ....
Multiple Script Execution On "Submit"
I have a webpage that accepts user information using an HTML form. When the "submit" button is pressed, the "action" executes a PHP script on a remote server. Basically, I have no control over this remote script. So, what I'd like to do is keep track of how many people fill out that form. I wasn't sure if it was possible to have two scripts execute (the remote script and a counter script) when the user clicks "submit", so I thought I'd ask here. Anyone know if this is possible? Maybe using a mix of javascript to call multiple post commands? I don't want to use Javascript to count the number of submissions - I'd prefer to use PHP so I can at least mask the code.
Another "Fatal Error: Call To Undefined Function: Mysql_connect()"Question
I am getting the following error when I try to view a test page in my browser. This test page just reads a table in mysql and outputs the results. Fatal error: Call to undefined function: mysql_connect() in /var/web/public/test.php on line 2 I'm using: Apache 2 MySQL 4.1.12 PHP 4.4.0 I have tried upgrading PHP to PHP5. I went back down to PHP4. I verified that mysql.so was being loaded. I tried using the OLD_PASSWORD feature in mysql. Verified that the PHP module is loaded in apache. What is weird however (at least I think) is when I run the following via telnet: php ./test.php It pulls up the page, connects successfully to the database and displays the records. No error message.
|