JQuery Learning (4-2-php server side 1), jquery4-2-php

Source: Internet
Author: User
Tags php server

JQuery Learning (4-2-php server side 1), jquery4-2-php


Main Content: describes the Image Upload process, involving PHP and JQuery;

1. Read the configuration file and connect to the MySQL database;

The configuration file mainly includes the user name and password;

3-5.php

<? Php/** version: 20141108 * // ** defines a constant */define ("EQUAL", "="); define ("SPACE ",""); function get_content ($ file) {if (! File_exists ($ file) return false; return file_get_contents ($ file);} function get_config ($ str, $ ini, $ type = "string ") {if ($ type = "int") {$ config = preg_match ("/". preg_quote ($ ini ). "= (. *);/", $ str, $ res); if ($ config = 0) return false;} else {$ config = preg_match ("/". preg_quote ($ ini ). "= \"(. *) \ ";/", $ str, $ res); if ($ config = 0) return false;} $ result = explode (EQUAL, $ res [0]); return preg_replace ("/(\" | \ '| ;)/" , SPACE, $ result [1]) ;}?>

2. Connect to the MySQL database;

The odbc class provided by PHP is used here;

First install the data source driver, class such as mysql-connector-odbc-5.3.4-win32; then in ODBC data source management where the configuration is OK.



2.1 database write connection

<?php/** version : 20141109* made dy : neojos*/include_once("3-5.php");class dbSource{function __construct(){$dbString=get_content("config.ini");$server=get_config($dbString,"server");echo $dbname=get_config($dbString,"userName");echo $dbpwd=get_config($dbString,"password");odbc_connect("DRIVER={MySQL ODBC 5.3 ANSI Driver};",$dbname,$dbpwd) or handle_error("",odbc_error()); }function handle_error($user_error_message,$system_error_message){header("Location:3-6.php?"."error_message={$user_error_message}&"."system_error={$system_error_message}");exit();}}$db=new dbSource();?>

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.