JQuery學習(4-2-php伺服器端1),jquery4-2-php

來源:互聯網
上載者:User

JQuery學習(4-2-php伺服器端1),jquery4-2-php


    主要內容:介紹圖片的上傳過程,涉及PHP跟JQuery;

    1. 讀取設定檔,串連MySQL資料庫;

       設定檔主要有使用者名稱和密碼;

3-5.php

<?php/** version : 20141108*//** 定義一個常量*/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. 串連MySQL資料庫;

    這裡使用PHP提供的odbc類;

    首先安裝資料來源驅動,類如mysql-connector-odbc-5.3.4-win32;然後在ODBC資料來源管理其中配置就OK了。



    2.1 寫資料庫的串連操作

<?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();?>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.