PHP error: Cannot modify header information


You cannot use header() once text has been output to the browser. As your header.php include presumably outputs HTML, header() cannot be used.
You can solve this in a couple ways:
  • Move the if statement above the header include (this won't work, as you've indicated in comments that header.php sets the uid session and other vital stuff).
  • Call ob_start() at the top of the script to buffer the output.

You can't issue HTTP headers after you have outputted content.

unction Redirect($url) {
        flush(); // Flush the buffer
        header("Location: $url"); // Rewrite the header
        die;
    }


function Redirect($url) {
        flush(); // Flush the buffer
        ob_flush();
        header("Location: $url"); // Rewrite the header
        die;
    }


To ensure your error reporting level is the same across environments, you can set it in your application using error_reporting() and ini_set('display_errors', 1)
Also check your .php files for any whitespace before the opening tag and after the closing tag.
In addition to the points mentioned above, ensure you are not outputting anything before the headers are set, for example the following code would produce an error similar to the one you are receiving:
echo 'Hello, World';
header('Location: http://www.somesite.com');

PHP Curl check for file existence


a PHP program that downloads a pdf from a backend and save to a local drive.

$url = "http://wedsite/test.pdf";
$path = "C:\\test.pdf;"
downloadAndSave($url,$path);

function downloadAndSave($urlS,$pathS)
    {
        $fp = fopen($pathS, 'w');

        $ch = curl_init($urlS);

        curl_setopt($ch, CURLOPT_FILE, $fp);
        $data = curl_exec($ch);

        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        echo $httpCode;
        //If 404 is returned, then file is not found.
        if(strcmp($httpCode,"404") == 1)
        {
            echo $httpCode;
            echo $urlS; 
        }

        fclose($fp);

    }

You can do this with a separate curl HEAD request:
curl_setopt($ch, CURLOPT_NOBODY, true);
$data = curl_exec($ch);

$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
When you actually want to download you can use set NOBODY to false.

PHP: How do I enable error reporting?

How to create update or remove symbolic or soft link Linux


Symbolic links , Symlink or Soft link in Unix are very important concept to understand and use in various UNIX operating systems e.g. Linux , Solaris or IBM AIX. Symlinks gives you so much power and flexibility that you can maintain things quite easily.I personally feel that along with find, grep and other UNIX commands, command to create soft link and update soft link i.e. ln -s  is also must for any one working in UNIX machine. Whenever I do scripting or write any UNIX script I always write for symlinks rather than pointing to absolute path of directories in UNIX. It gives you flexibility of changing the symlink or soft link without making any change on your tried and tested scripts. I have worked on many different core Java projects which run on Linux and UNIX machine and make extensive use of UNIX symbolic links or symlinks. All my project which are on finance domain and on electronic trading systems have there server running on Linux,  Since speed is major concern in online stock or futures trading where orders has to hit the market within micro seconds Linux server is ideal choice for electronic and fix trading systems and since your server is on UNIX you have to be expert of Unix command to work efficiently and these articles are my result of those effort to learn and share new UNIX commands. In this UNIX fundamental tutorial we will see How to create soft link in UNIX, How to update soft link and Difference between Soft link and Hard link in Unix and Linux. By the way this UNIX command tutorial is  in continuation of my earlier article top networking commands in Unix  and CVS command examples ,  if you haven’t read already you may find some useful information based on my experience in Unix and Linux commands.



First difference between soft link and hard link is that  Unix Soft links are pointers to programs, files, or directories located elsewhere (just like Windows shortcuts) , while Unix Hard links are pointers to programs and files, but NOT directories.
2) Second major difference between UNIX soft link and hard link is that If the original program, file, or directory is renamed, moved, or deleted, the soft link is broken and it will show in red color if you using ls -lrt --color option. On the other hand, If the original program or file is renamed, moved, or deleted, the hard link is NOT broken
3) One not so important difference on soft link vs hard link is that,  If you type ls -F you can see which files are UNIX soft links because they end with @

4)  Another difference between soft link vs hard link is how you create them, To create a soft link called "current" that points to a file or directory called "new_package", use this: ln -s new_package latest  to remember this command always remember that name of soft link comes as last argument. On the other side to create a UNIX hard link called myhardlink.txt that points to a file called myfile.txt, use this: ln myfile.txt myhardlink.txt

5) One more significant difference on soft link and hard link on UNIX or Linux is that, soft link can point to a network mounted directory also. For creating unix soft link remember to use option "-s" with UNIX link command "ln". While, Hard links in UNIX cannot span disk drives, so you CANNOT have a hard link on /dev/hdb that refers to a program or file on /dev/hda

FTP 550 Access is denied Error

Probably the Firewall from Client A which is preventing this. FTP also requires a data channel to send its information

How to list directory content of remote FTP, recursively?

IT can do almost everything bash can do, albeit remotely.


$ lftp mirror.3fl.net.au
lftp mirror.3fl.net.au:~> ls                          
drwxr-xr-x  14 root     root         4096 Nov 27  2007 games
drwx------   2 root     root        16384 Apr 13  2006 lost+found
drwxr-xr-x  15 mirror   mirror       4096 Jul 15 05:20 pub
lftp mirror.3fl.net.au:/> cd games/misc
lftp mirror.3fl.net.au:/games/misc>find
./
./dreamchess/
./dreamchess/full_game/                                                      
./dreamchess/full_game/dreamchess-0.2.0-win32.exe                                      
./frets_on_fire/
./frets_on_fire/full_game/                                                      
./frets_on_fire/full_game/FretsOnFire-1.2.451-macosx.zip                                  
./frets_on_fire/full_game/FretsOnFire-1.2.512-win32.zip
./frets_on_fire/full_game/FretsOnFire_ghc_mod.zip
./gametap_setup.exe
......
lftp mirror.3fl.net.au:/games/misc> du gametap_setup.exe 
32442   gametap_setup.exe
lftp mirror.3fl.net.au:/games/misc> du -sh gametap_setup.exe 
32M     gametap_setup.exe
lftp mirror.3fl.net.au:/games/misc> 

Difference between active and passive FTP?


Active and passive are the two modes that FTP can run in. FTP uses two channels between client and server, the command channel and the data channel, which are actually separate TCP connections. The command channel is for commands and responses, the data channel is for actually transferring files. It's a nifty way of sending commands to the server without having to wait for the current data transfer to finish.
In active mode, the client establishes the command channel (from client port X to server port 21(b)) but the server establishes the data channel (from server port 20(b) to client port Y, where Y has been supplied by the client).
In passive mode, the client establishes both channels. In that case, the server tells the client which port should be used for the data channel.
Passive mode is generally used in situations where the FTP server is not able to establish the data channel. One of the major reasons for this is network firewalls. While you may have a firewall rule which allows you to open up FTP channels to ftp.microsoft.com, Microsoft's servers may not have the power to open up the data channel back through your firewall.


Active mode:
  • Client opens up command channel from client port 2000(a) to server port 21(b).
  • Client sends PORT 2001(a) to server and server acknowledges on command channel.
  • Server opens up data channel from server port 20(b) to client port 2001(a).
  • Client acknowledges on data channel.
Passive mode:
  • Client opens up command channel from client port 2000(a) to server port 21(b).
  • Client sends PASV to server on command channel.
  • Server sends back (on command channel) PORT 1234(a) after starting to listen on that port.
  • Client opens up data channel from client 2001(a) to server port 1234(a).
  • Server acknowledges on data channel.

Multiple array in php


If the ID, topic and description are all in the correct order in each comma delimited string you are supplying to the script, you could use the following to create a single array key'd by the ID:


$id = explode(',',$data->id);
$topic = explode(',',$data->topic);
$description = explode(',',$data->description);

foreach($id as $key=>$val)
{
    $results[$val]['topic'] = $topic[$key];
    $results[$val]['description'] = $description[$key];
}



$newArray=array_merge($topic,$description,$third_array);
foreach($newArray as $key=>$value)
{
echo "$key- $value <br/>";
}

SQL Injection Prevention

the value should only be a positive integer value, since it's an id number. We do sometimes use other variables that could be a letter, or a string of text, for example, the search results pages.


$variable = "0";
if (isset($HTTP_GET_VARS["id"])) {
  $variable = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS["id"] : addslashes($HTTP_GET_VARS["id"]);
}

Should I be using mysql_real_escape_string

basic SEO factors

It is quite easy to learn the basic SEO factors if you spend a
couple hours researching on the web. Here is a quick summary of
them:

-You need to have unique and useful content.
-You need to have quality and relevant backlinks.
-Your title tags should be unique and contain your main keywords.
-Your permalinks should be based on keywords rather than symbols.
-Your website shouldn't have many folders, and its pages should
be interlinked.

If you follow these guidelines soon you'll start getting a decent
amount of traffic from Google.

You should be careful, however, to not become greedy and start
over-optimizing your website, which is a mistake I see many new
bloggers and webmasters doing.

Here are the most common forms of search engine over-optimization I
see around:

1. Repeating the main keywords over and over again in the body
of the article to increase the keyword density.

2. Using the bold and italic typefaces over and over again on the
main keywords of the page.

3. Creating footer links with optimized and unnatural anchor texts
pointing to internal pages.

4. Getting backlinks from low quality sources (e.g., web directories
and dofollow blogs) with optimized and unnatural anchor texts.

5. Getting too many backlinks with the same anchor text.

6. Exchanging with or buying links form low quality or unrelated
websites.

These tactics might work in the short term, as the person applying
them might see an increase in the search rankings and organic
traffic.