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:
I have few urls like
I want to redirect it to http://www.mydomain.com/folder1/ page but I want to show on browser url the original urls likes
Please note that I do not have folders statecode1-folder1 and statecode2-folder1
Currently I use the below .htaccess which redirects but it changes the address bar
Initially i thought this could be the case as i was uploading around 12mb csv but then i tried with just 4kb but still getting the same error.
I don't really understand what could be the problem - the uploading works fine if i try using normal html form submit but as we don't want to manually browse the file - we decided to go this route and it's not working.. What a pain.
On the other hand why do you say it will not work for size in MB ? Is there any other auto upload way for such big files ?
Are you able to get the other post data transferred if you comment out the file_get_contents line?
I can't test that as it's some external company site where we have to upload our data so that they can do what they are suppose to do with the data.
Well i use below code as initial request - so they receive the post data and they send us back id which we need to send along with the file -
$agent = "Mozilla/5.0";
$cURL_Session = curl_init();
curl_setopt($cURL_Session, CURLOPT_USERAGENT, $agent);
curl_setopt($cURL_Session, CURLOPT_POST, 1);
curl_setopt($cURL_Session, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($cURL_Session, CURLOPT_FOLLOWLOCATION, 1);
$result = curl_exec($cURL_Session);
$postdata = array();
$postdata['profileName'] = 'tsunami';
$postdata['tName'] = 'abc';
$postdata['langCode'] = 'en_GB';
It using the same process - so am sure it's only file auto upload bit that's not working for us. As i said it works using normal html form submit.