Close

MySQL combine two columns and add into new column

MySQL combine two columns and add into new column [code language=”sql”] UPDATE tablename SET combined = CONCAT(zipcode, ‘ – ‘, city, ‘, ‘, state) [/code] Output: zipcode – city, state MySQL combine two columns and add into new column where year is a number [code language=”sql”] UPDATE `tablename` SET cat_path = CONCAT(year, ‘/’, name) WHERE…

PHP: Recursive Directory Navigation

[code language=”php”] function readpath($dir,$level,$last,&$dirs,&$files){ //print $dir." (DIR)\n"; $dp=opendir($dir); while (false!=($file=readdir($dp)) && $level == $last){ if ($file!="." && $file!="..") { if (is_dir($dir."/".$file)) { readpath($dir."/".$file,$level+1,$last,$dirs,$files); // uses recursion $dirs[] = "$dir/$file"; // reads the dir into an array } else{ $files[] = "$dir/$file"; // reads the file into an array } } } } /* From PHP.NET…

PHP: Check broken links using curl

[code language=”php”] function check_url($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec($ch); $headers = curl_getinfo($ch); curl_close($ch); return $headers[‘http_code’]; } $mainurl = "http://www.google.com"; $myurl = "http://www.google.com/gggg"; $mainsite = check_url($mainurl); $satus = check_url($myurl); if($mainsite == ‘200’){ if($satus == ‘200’){ echo "Its works"; }else{ echo "broken url"; } }else{ echo…