Tag Archives: PHP

PHP Security

script-secuity




When it comes to PHP, some 99% of amateur sites and 60-70% of all sites use the professional scripting language called PHP. But is it safe to use PHP? Does the implementation of the language not have any gaps that are critical to the operation of our applications? But remember that security problems do not arise just from the language itself, but also from the programming skills of those who write PHP scripts. Of course, most of the errors can […]

Create Database and Tables in PHP MySQL

php-mysql




As We know database holds one or multiple tables. Here in this post you will learn how create database tables in Mysql Create a Database We use the CREATE DATABASE statement to create a database in MySQL. Syntax CREATE DATABASE database_name To get PHP to execute the MYSQL statement we must use the mysql_query() function. This function is used to send a query or command to a MySQL connection. For Example The following example creates a database called “school_database”: <?php […]

PHP Interview Questions and Answers – Part 4

php-interview-questions-answers




1- What is the difference between ereg_replace() and eregi_replace()? eregi_replace() function is identical to ereg_replace() except that it ignores case distinction when matching alphabetic characters. 2- How do I find out the number of parameters passed into function9. ? func_num_args() function returns the number of parameters passed in. 3- If the variable $a is equal to 5 and variable $b is equal to character a, what’s the value of $$b? 100, it’s a reference to existing variable. 4- How To […]

Use Multiple Headers in a PHP

php5




With PHP, you can send multiple HTTP headers with file_get_contents() . you can also send information such as HTTP_ACCEPT, HTTP_ACCEPT_LANGUAGE, and HTTP_CONNECTION with file_get_contents(). In this post, I have write a complete example code to set multiple headers; an Authorization header and a Content-Type header using PHP and make POST request using file_get_contents(). <?php $options = [“http” => [ “method” => “POST”, “header” => [“Authorization: token ” . $access_token, “Content-Type: application/json”], “content” => $data ]]; $context = stream_context_create($options); ?> Now […]

Rename Product Image in SQL Query Oscommerce

oscommerce




How to Rename Product Image in SQL Query in osCommerce. In Oscommerce it is simple to rename the product image in sql query. IN the below is the simple script to sove this require(‘includes/application_top.php’);  $products_query = tep_db_query(“select * from products”);  while ($products_values = tep_db_fetch_array($products_query)) {   $products_id = $products_values[‘products_id’]; $products_image = $products_values[‘products_image’]; $image = $products_image.’.jpg’; //echo $image; //echo $products_id; //echo $products_image; $sql = “update products set products_image = ‘” .$image .”‘ where products_id = ‘” . (int)$products_id . “‘”; $update_query […]

Php Interview Questions and Answers – Part 3

php-interview-questions-answers




1- What is the difference between CHAR and VARCHAR data types? CHAR is a fixed length data type. CHAR(n) will take n characters of storage even if you enter less than n characters to that column. For example, “Hello!” will be stored as “Hello! ” in CHAR(10) column. VARCHAR is a variable length data type. VARCHAR(n) will take only the required storage for the actual number of characters entered to that column. For example, “Hello!” will be stored as “Hello!” […]

Top Anti-Spam WordPress Plugins Combat Spam Attack

TOP-Anti-Spam-WordPress-Plugins




Do you get bag full of spams everyday? Your answer may be ‘ No ’. But, the truth is 99% of bloggers struggle with their spam issues most of the time. Spam is an universal headache for bloggers. There is no denying in this. Have you ever thought – Spams take how much time of your blogging career or your life? Example: Suppose you spend 10 min everyday to segregate and delete spams on your WordPress blog. It comes to […]

Wrapping Text in PHP

wrapping text in php




Sometimes we need to wrap text to exactly accommodate a certain width of text or allowing browsers to wrap text whenever required. You can use PHP’s wordwrap() function to wrap a string into new lines when it reaches a specific length. This function limits text display to a particular column size, thereby allowing precise control over how text is rendered on a Web page. By default, wordwrap() wraps strings at column 75 using the standard newline sequence. Below example is […]

Php Interview Questions and Answers – Part 2

job-interview-question




1- Why doesn’t the following code print the newline properly? <?php $str = ‘Hello, there.nHow are you?nThanks for visiting techpreparation’; print $str; ?> Because inside the single quotes the n character is not interpreted as newline, just as a sequence of two characters – and n. 2- Would you initialize your strings with single quotes or double quotes? Since the data inside the single-quoted string is not parsed for variable substitution, it’s always a better idea speed-wise to initialize a […]

Mysql Full Text Search – Mysql

mysql-full-text-search




In this post you’ll learn how to build a basic full-text search engine using PHP and MySQL. What is full text search? The full-text search in mysql allows you to quick and very accurate search for single or multiple keywords from multiple columns. It does this by using an index on the columns that you want to search. There are a few limitations that you should know. Indexed columns can only be TEXT, MySQL does not by default index words […]