It seems to be the very first call to header that fails. It fails even if I stick an echo before it (and echoed text is not displayed). If I used echo 'x'; die; it displays x, but obviously doesn't attempt to change headers.
Do you know if there are required permissions to use header function?
It fails even if I stick an echo before it (and echoed text is not displayed).
Aha! If the echoed text is not displayed for an echo() BEFORE the first header(), then it seems that code is not being entered. An echo() should output something recognisable, even if the total result is a mangled chunk of HTML. This also ties in with the ERR_EMPTY_RESPONSE you mentioned in your original question.
The next place I would go looking is Apache and PHP version differences between the working and failing sites.
AFAIK, there are no special permissions required to use header(). ie, from a permissions point of view, header() is as good or bad as echo().
Sorry, I may have confused you with my last reply. Should have put in dot points?
1. The first thing to look for is why the first echo() doesn't.
2. If you got nowhere looking for that, then look for differences between the servers (which now appear to be irrelevant.)
Hello experts. Is it possible to create file headers in PHP? In C, I could rely on size of data types to create file headers so that if I want a specific information from the file header, I had to seek to the appropriate byte location and read what I wanted.
I am seeing this to be difficult in PHP. I don't know how I can save, for instance, the length of a string in a file header and later retrieve it at a known byte location.
I started with something like the following:
Because the variables can take different data types in PHP, I don't know how I can read the header information before dealing with the file. I can't tell the length that will take me to, for instance, $headerLength in the file so that I can read it since I wouldn't know the length of a particular data. It seems the number of bytes can vary for different headers of different files. Actually, I am a newbie in PHP and I don't know if there is any other way that will make such a task possible. Please help.
If you really need to work with binary files in PHP you need to use the pack and unpack functions, along with the C like file functions (fopen, fseek, fread etc.), however if you need to work with binary files you probably really need to consider whether PHP is an appropriate language for your application.
I think I cannot use PHP for my task. I tried to write an integer value which could have occupied 4 bytes (or 2 bytes) of memory but the value was written as two sequence of characters. This means that I cannot rely on writing such values in PHP. 27 was saved as it is of two characters '2' and '7'. So 274 will also be saved as 3 characters where in C I would have assumed that to be of 4 sequence of bytes. I think PHP is unsuitable for such a task. Or maybe there are other ways around which I don't know and need to be taught.
This bit of code shows you how to write an integer to an ASCII text file, then (as a four byte long) to a binary file. The key thing is that pack is used to convert the integer into a character array equivalent to its binary representation before writing it. The default behavior of PHP when writing variables to a file is to convert them to strings.
$myinteger = 234;
$fp1 = fopen("ascii_text_file.txt", "w");
fwrite($fp1,$myinteger); // writes a text representation of my integer;
$fp2 = fopen("binary_file.dat", "w");
$data = pack("l",$myinteger); // create char array equivalent to a 'long' containing $myinteger
Hi all. I am a beginner in php programming. Given a web page with links, I would like to know how I can send the selected link to a php script so that it will return the appropriate page requested. I don't if this can be done in an anchor ( <a> ) tag. Please help.
Ok I'm not quite sure what you mean. A link on a page already loads a file from the webserver (eg: <a href="http://www.somesite.com/mypage.php">MyLink</a>). The link I gave in the sample would load mypage.php from the webserver.
If you mean you wish to use one single entry point (eg: index.php) for all page requests then you could do this using the querystring. Just set a parameter with the page you want to load and put the entire url in the A tag.
So in the second case you would end up with something like:
As of now the "previous" works for every other month (i.e. December, October, August... etc) and the "next" is not working at all (blank screen). I've tried different methods for getting the new date and month but with no luck. Any help is greatly appreciated.
as far as i understand this is a valid mail function, but on the server it won't send anything to anyone, even my hotmail account .....What am i doing wrong ? this is all the code i have for this particular function so that i can test if it will work to submit feedback results to another mailbox....
(obviously the mail $to email is the one i am only using for this forum post )
i have asked the server support team and they say that this should work?
I'm not an expert in PHP mail, but I think the mail server needs to be set in the php.ini file if using Windows. If Linux, then you'll have to do something different to use a remote SMTP server. Here are a couple of links that might help: