Archive for the ‘quick fix’ Category

quick fix | No Comments | July 22nd, 2021

Invalid field count in csv input on line 1

I was trying to import a massive csv dataset into phpMyAdmin and it kept throwing error:Invalid field count in csv input on line 1

This was very annoying as it was all being done the way it always works for me!

To solve this I had to do the following:

  • Import
  • Browse for your csv file.
  • Select CSV using LOAD DATA (rather than just CSV)
  • Change “Fields terminated by” from “;” to “,”
  • Make sure “Use LOCAL keyword” is selected.
  • Click “Go”

Done!

quick fix | No Comments | February 8th, 2021

Get the first sentence with PHP

use this function ::

function first_sentence($content) {

    $pos = strpos($content, '.');

    if($pos === false) {
        return $content;
    }
    else {
        return substr($content, 0, $pos+1);
    }

}

and then call it like ::

echo first_sentence($content);

quick fix | No Comments | February 8th, 2021

Remove unnecessary space between lines in dreamweaver

Sometimes code in dreamweaver got space in between. This will make your code very lengthy and hard to read. To remove the space you can use this method in Dreamweaver

1. Open the file (source code)
2. Click CTRL + F
3. Select “Current document” in “Find in” (You can also select the folder if you have multiple files)
4. Search in “Source code”
5. Tick “Use regular expression”
6. Type “[\r\n]{2,}” (without quotes) in “Find”
7. Type “\n” (without quotes) in “Replace”
8. Press “Replace All”

You are done! All the spaces gone.

quick fix | 1 Comment | January 16th, 2021

prevent hotlinking with .htaccess

add this code in your .htaccess file

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} .*jpe?g$|.*gif$|.*png$ [NC]

RewriteCond %{HTTP_REFERER} !^$

RewriteCond %{HTTP_REFERER} !yoursiteurl\.com [NC]

RewriteCond %{HTTP_REFERER} !google\. [NC]

RewriteCond %{HTTP_REFERER} !live\. [NC]

RewriteCond %{HTTP_REFERER} !yahoo\. [NC]

RewriteCond %{HTTP_REFERER} !msn\. [NC]

RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]

RewriteRule .* – [F]

and replace this :: yoursiteurl with your site URL

quick fix | 4 Comments | April 2nd, 2009

Formatting money / currency using PHP

// Our original decimal number

$number = 21357.44;

// Let’s use PHP’s built-in function to format the number into US currency

$formatted = number_format($number, 2);

// The following statement will print 21,357.44

echo “\$” . $formatted;

?>

Mode rewrite, quick fix | No Comments | March 2nd, 2009

parse php in html page

For that add this code in .htaccess file.

AddType application/x-httpd-php .php .htm .html

quick fix | No Comments | February 12th, 2009

Remove Special Characters

A regex that will check for any characters that are not in the list below and return true if any unknown characters are found

a-z
A-Z
0-9
_ (under-dash)
- (hypen)
(space)

$text = preg_replace(‘/[^a-zA-Z0-9_ -]/s’, , $text);