Squeeze some time to write a blog-php& MySQL practice, write blog-php_php tutorial

Source: Internet
Author: User
Tags php and mysql

Squeeze some time to write blog-php&mysql practice, write blog-php


Hi

In the evening to eat hot pot, squeeze a little time to write something, don't be found by the boss OH

1. PHP and MySQL

Article release system behind the table

5.2 Creating configuration files and initialization files

For unified configuration and ease of administration, there is also a reduction in code redundancy.

Config.php and connect.php, respectively.

config.php

/*
* Configuration file
*/
Information about the configuration database
Since it is a constant, it is used directly with define
Define (' HOST ', ' 127.0.0.1 ');
Define (' USERNAME ', ' root ');
Define (' PASSWORD ', ');

connect.php

/*
* Files linked to the database
* Mainly link to the database server and select the database.
* Special is to set character sets.
* Then want to judge each operation
*/

Include Configuration files
Require_once ' config.php ';

Even library
if (! $con =mysqli_connect (Host,username,password)) {
echo Mysqli_error ($con);
}

Select Library
if (mysqli_select_db ($con, ' info ')) {
echo Mysqli_error ($con);
}

Character
if (Mysqli_query ($con, ' Set names UTF8 ')) {
echo Mysqli_error ($con);
}

After the completion of testing the link file is OK. Mysqli and MySQL are ok here, as long as the format is correct.

5.3 Publishing Articles

Article Publishing Interface article.add.php





Untitled Document













Backend Management System

Publish an article


Manage Articles


All rights reserved


It's not so beautiful, it's learning.

Article release Handler article.add.handle.php

Require_once ('.. /connect.php ');
Put the information passed over to the storage, before the storage of all the information to verify.
if (! ( Isset ($_post[' title ') && (!empty ($_post[' title ')))) {
echo "";
}
$title = $_post[' title '];
$author = $_post[' author ');
$description = $_post[' description ');
$content = $_post[' content '];
$dateline = time ();
$insertsql = "INSERT into article (title, author, description, content, Dateline) VALUES (' $title ', ' $author ', ' $descriptio n ', ' $content ', $dateline) ";
if (Mysqli_query ($con, $insertsql)) {
echo "";
}else{
echo "";
}
?>

Note the function and connection of the two, that is, the add page to pass things to handle processing

------------------------

Because I have encountered the previous not seen the garbled problem ... On my knees to solve the problem .... Hope everyone wamp Environment, Mysql,zend, browser has been set to Utf8,apache configuration file added Adddefaultcharset UTF-8, the problem still exists, I faint ah .... )

http://www.bkjia.com/PHPjc/1077133.html www.bkjia.com true http://www.bkjia.com/PHPjc/1077133.html techarticle squeeze some time to write blog-phpmysql practice, write blog-php hi evening to eat hot pot, squeeze a little time to write something, don't be the boss found Oh 1, PHP and MySQL Five, the article released the system after the platform ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.