If you’ve created you own custom content management system using PHP, you may have noticed problems inserting data. One of the problems could be that your data may have characters that prevent it from being inserted. Some of the character that would cause this type of problem are single or double quotes, backslash, and NUL characters.
You can escape these problematic characters using the PHP function addslashes(). As explained by the PHP manual: It returns a string with backslashes before characters that need to be quoted in database queries etc. These characters are single quote (‘), double quote (“), backslash (\) and NUL (the NULL byte).
As you can see from my example below, I first run the content through the addshashes function and than return it to the same named string “$Page_Content” before passing it to my SQL UPDATE or INSERT statement.
$Page_Content = addslashes($Page_Content);
$query = "UPDATE site_content SET Page_Title='$Page_Title', Page_Content='$Page_Content' WHERE id_f='$id_f'";
First you log in using your terminal application by typing the flowing SSH command:
After that, you will be prompted to enter your password. As you enter your password, the text will be hidden. Next we should switch to the “root” user. You can do so by typing the following in your terminal window:
su – root
You will have to enter a password once more. Now navagate to where you would like to store your MySQL database file. For an example of changing the directory to the “public_html” direcotry, type this:
Now you can back up your db here using the following command. This command will backup all of your databases. I also chose to compress them after the pipe “|” as a gzip file. Type the following but be sure to change the user name and password to your info:
mysqldump -u yourusername -p yourpassword –all-databases | gzip >databasebackup.sql.gz
You can also target single database using the following:
mysqldump -u yourUserName -p yourDBName | gzip >databasebackup.sql.gz
You may want to dynamically change the way your flash file behaves based on where it’s hosted. To do so, you should utilize the “_url” variable to obtain the absolute path of your flash file. Continue reading “How to validate Flash absolute url paths”
How to swap depth using AS3 via setChildIndex. This will fix the Warning: 1060: Migration issue: The method getNextHighestDepth is no longer supported. Continue reading “How to Swap Depth using AS3 via setChildIndex”
Want to remove the last character from your text. Just use Substr_Replace. This is how. Continue reading “PHP Remove last character from string”
How to filter / remove duplicate items in your database query result using DISTINCT
Continue reading “Select UNIQUE or DISTINCT MySQL/PHP Queries”
How to select and display records from MySQL table using the DISTINCT keyword for unique data.
Continue reading “MySQL DISTINCT to Remove Duplicate Listing”
Here is some code to help sort the order of your directory output. This is greate for creating PHP FTP applications.
Continue reading “Sort Directory Listings”
Now you can send emails from your web sites with full control over design style and functionality. PHP is the way to go for online email form. Here is how to get started.
Continue reading “PHP Email Form Easy”