亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? using databases in php.html

?? a collection of mega hacking tools
?? HTML
字號(hào):
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">



<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

	<title>Using Databases In PHP </title>

	

	<meta http-equiv="Content-Type" content="text/html charset=utf-8" />

	<meta content="Copyright 2001 SpiderMan" name="Copyright" />

	<meta content="SpiderMan" name="Author" />

	<meta content="English" name="Language" />

	

	<style type="text/css">

	<!--

		body {font: 12px Verdana, Arial, Helvetica, sans-serif}

	

		table.example {width: 200px; font-size: 12px; text-align:left}

		tr.exampletop {background-color: #EBEBEB}



		pre.example {background-color: #EBEBEB; border: 1px solid #000000; padding: 3px, 3px, 3px, 3px; text-align: left; width: 550px; margin-left: auto; margin-right: auto}

	

		p {text-align: left;}

		p.para {text-indent: 12px}

	

		div.lastupdate {text-align: right}

		/* hack so IE will center my stuff since it doesn't recognize margin: auto */

		div.center {text-align: center}



		span.function {color: gray; font-weight: bold}

		span.term {color: gray; font-style: italic}

	

		a:link {text-decoration: underline; color: #003F7F}

		a:visited {text-decoration: underline; color: #003F7F}

		a:hover {text-decoration: underline; color: #CC0000}



		h2 {font-size: 12px}

		h1.title {font-weight: normal; text-align: center; font-size: 12px}



		pre.example {background-color: #EBEBEB; border: 1px solid #000000; padding: 3px; text-align: left; width: 500px; margin-left: auto; margin-right: auto}

	-->

	</style>

</head>



<body>

	<h1 class="title">

		<strong>Using Databases In PHP (ver. 1.0.0)</strong>

		<br />

		by: <a href="mailto:spiderman@witty.com">SpiderMan</A> of <a href="http://blacksun.box.sk">Black Sun Research Facility </a>

	</h1>

	<h2>Introduction:</h2>

	<p class="para">

		This isn't quite a full blown tutorial, I like to think of it as a mini-tutorial. This &#8220;mini-tutorial&#8221; will cover some of the most commonly used functions. There won't be a background section; we're going to go straight to work. Today, I'm going to discuss (if the title didn't give it away) connecting to and using a database with php. The database will be MySQL because it's just sooo darn popular.

	</p>

	<h2>Down To Work:</h2>

	<p class="para">

		The first thing we need to do is connect to the database.

	</p>

	<div class="center">

		<pre class="example">

mysql_connect("somehost", "username", "password") or die ("Can't connect!");

</pre>

	</div>

	<p>

		This will try to connect to the database on somehost and login with &#8220;username&#8221; as the username and &#8220;password&#8221; as the password. If it can't, it will output an error message saying that it can't connect. For your own code be sure to change somehost to your host (most of the times it's localhost, ask your admin), username to your username (duh), and password to your password. Another way to connect to a database is to open a persistent connection. To do this, use the <span class="function">mysql_pconnect</span> function and pass it the same arguments as <span class="function">mysql_connect</span>. Why open a persistent connection? When you call <span class="function">mysql_pconnect</span>, instead of going out and opening a connection to the database, it sees if one is already open, if it is, the script will use it. Also, when the script has finished executing, the connection to the database will not automatically be closed like it is when using <span class="function">mysql_connect</span>. This way the connection can be used later on. Using a persistent connection is a good idea if your scripts constantly need to connect to the database.

	</p>

	<p class="para">

		After we have opened a connection to the database, we then select a database.

	</p>

	<div class="center">

		<pre class="example">

mysql_select_db("database_name") or die("Can't select database!");

</pre>

	</div>

	<p>

		This will try to select the database named &#8220;database_name&#8221; (for your own code change it to the name of your database). If it can't select the database, it will output and error. Once you're actually connected to a database, you will want to query a table in the database to get whatever you want done. A query looks like this:

	</p>

	<div class="center">

		<pre class="example">

mysql_query("Some query");

</pre>

	</div>

	<p class="para">

		Common queries are <span class="term">SELECT</span> and <span class="term">INSERT</span> For full documentation go to the mysql web site (<a href="http://www.mysql.com" title="Click to visit the MySQL website (link opens in a new browser window)." target="_blank">http://www.mysql.com</a>). Another common php function is <span class="function">mysql_num_rows</span>; if it isn't obvious this gets the number of rows from a query. Here is an example of how it can be used with <span class="function">mysql_query</span>:

	</p>

	<div class="center">

		<pre class="example">

&lt;?php

  $result= mysql_query("SELECT * FROM some_table");

  $number_of_rows= @mysql_num_rows($result);

      

  if ($number_of_rows == 0)

  {

    echo "Sorry there are no rows";

  }

  else {

    echo "Yes! we found some rows!";

  } 

?&gt;

</pre>

	</div>

	<p>

		Now you may be wondering why I put the @ sign before <span class="function">mysql_num_rows</span>. In php, the @ sign suppress errors; I put it in front of <span class="function">mysql_num_rows</span> so that if there are no rows, MySQL will not output a bunch of errors. So when would <span class="function">mysql_num_rows</span> be useful? Well, you could use it for an authentication script which searchs the database for a username and password and if it doesn't find any (i.e. if no rows are returned), it tells the user that the username, or password, are not correct.

	</p>

	<p class="para">

		Another really useful function is <span class="function">mysql_fetch_array</span>, because it gets the rows and puts them in an array that contains the name of the rows. That way instead of having to access each row by number you can do it by name! For example, let's say that our database looked like this:

	</p>

	<div class="center">

		<table class="example" align="center" border="1" cellspacing="0" cellpadding="2" summary="Table of flags">

			<tr class="exampletop">

				<td>User</td>

				<td>Password</td>

			</tr>

			<tr class="example">

				<td>John</td>

				<td>afasdfadsfdsf</td>

			</tr>

			<tr class="example">

				<td>Billy</td>

				<td>tla;jrjealjwqsldajf</td>

			</tr>

			<tr class="example">

				<td>Mitch</td>

				<td>pqrtupipripewir</td>

			</tr>

		</table>

	</div>

	<p>

		We would use the following code to get the users' names and output them:

	</p>

	<div class="center">

		<pre class="example">

&lt;?php

  echo "The users in this database are: &lt;br&gt;";  

  $result= mysql_query("SELECT * FROM some_table");

      

  while ($row= mysql_fetch_array($result))

  {

    $username= $row["User"]; 

    echo "$username&lt;br&gt;";

  } 

?&gt;

</pre>

	</div>

	<p>

		This will output all the usernames in a database; you can add error checking if you like. The while statement is read &#8220;while there are rows that satisfy the query, put the contents of the row from the column &#8216;User&#8217; into the variable &#8216;username,&#8217; and print the usernames (each on a new line) to an HTML page.&#8221;

	</p>

	<p class="para">

		Now let's cover a couple of functions that actually work with the database. The first is <span class="function">mysql_create_db</span>, don't you just love how the functions are named you can figure out what they do just by looking at the function name, this one obviously creates a database. Here's how to use it:

	</p>

	<div class="center">

		<pre class="example">

&lt;?php 

  echo "I am going to try to create a database...&lt;br&gt;";

      

  if (mysql_create_db("test_database"))

  {

    echo "Hooray, I've created the database!&lt;br&gt;";

  }

  else { 

    echo "Darn couldn't create the database! because: ";

    echo "mysql_error() &lt;br&gt;";

  }

?&gt;

</pre>

	</div>

	<p>

		You can see I used a new function, <span class="function">mysql_error</span>, you don't really need to know too much about it, all it does is return the error string sent by MySQL. Now since we learned how to create a database, how's about we learn to delete one. To do that use the <span class="function">mysql_drop_db</span>, here is how to use it:

	</p>

	<div class="center">

		<pre class="example">

&lt;?php 

  echo "I am going to try to delete a database...&lt;br&gt;";

  $result= mysql_drop_db("test_database");

      

  if (!$result)

  {

    echo "Darn couldn't I couldn't delete the database!&lt;br&gt;";                   

  }

  else { 

    echo "Hooray, I've deleted the database&lt;br&gt;";   

  }

?&gt;

</pre>

	</div>

	<p>

		You can see that the syntax is very similar to that of <span class="function">mysql_create_db</span>, just pop the name of the database you want to delete into the function.

	</p>

	<p class="para">

		The next two items aren't functions, rather they are queries that you can use to manage an existing table. The following query will insert data into a database:

	</p>

	<div class="center">

		<pre class="example">

&lt;?php 

  echo "I am going to try to insert data into a table...&lt;br&gt;";

  $result= mysql_query("INSERT INTO test_database (username, password) VALUES 

	               (Rahim, adfjaldadfsdaf)");

      

  if (!$result)

  {

    echo "Darn couldn't I couldn't delete the database!&lt;br&gt;"; 

  }

  else { 

    echo "Hooray, I've deleted the database&lt;br&gt;";     

  }

?&gt;

</pre>

	</div>

	<p>

		This query should be pretty obvious, it inserts the data defined in between the parentheses into the rows. Just a little note to remember, the order in which you write out the column names is the order your data will be entered (i.e. a row with the contents Rahim will be entered under username, not password since we wrote username then pasword, if it was reveresd Rahim would be put under password).

	</p>

	<p class="para">

		The next query we've already gone over, I'm just going to add to it; after I'm done you should be able to use it to help create a simple search engine (upcomming tutorial)! For the sake of brevity I'll remove all the extra php stuff and just show you the &#8220;meat&#8221; of the code.

	</p>

	<div class="center">

		<pre class="example">

$result= mysql_query("SELECT name FROM some_table WHERE name=Joe AND 

         lastname=Sixpack OR lastname=Becker ORDER BY lastname LIMIT 20");

</pre>

	</div>

	<p>

		Now I know that looks like a long query, but it's not really all that bad. What it's pretty much saying is: &#8220;Get me the name from some_table where the name is Joe and the lastname is Sixpack or Becker, oh and by the way while your at it, put it in alphabetical order by the lastname; oh and one last thing, just get the first 20 results please.&#8221; MySQL has lots of other filters that you can add on to the SELECT statement, I highly suggest you download the MySQL documentation and give it a perusing.

	</p>

	<h2>Conclusion:</h2>

	<p class="para">

		Well that wraps up this &#8220;mini-tutorial&#8221;, you should use this as a quick reference for my other (upcomming) tutorials. If you found any errors or have any comments please e-mail me (<a href="mailto:spiderman@witty.com" title="Click to e-mail me.">spiderman@witty.com</a>), kindly direct questions to the message board.

	</p>

	<div class="lastupdate">Last updated: <strong>5/28/01</strong></div>

</body>

</html>

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产福利精品一区二区| 色94色欧美sute亚洲线路二| 亚洲免费电影在线| 久久综合狠狠综合| 欧美日韩精品二区第二页| 国产成人免费网站| 欧美日韩一区二区三区四区五区| 日本一道高清亚洲日美韩| 欧美色倩网站大全免费| 成人性生交大片免费看中文网站| 亚瑟在线精品视频| 亚洲码国产岛国毛片在线| 久久久综合网站| 日韩午夜在线影院| 欧美网站大全在线观看| 99国产精品久久久久久久久久久| 国内精品伊人久久久久av影院 | 久久综合狠狠综合久久激情 | 国产精品综合久久| 日韩不卡一区二区| 亚洲高清视频中文字幕| 亚洲欧美日韩综合aⅴ视频| 国产欧美一区二区在线| 久久奇米777| 久久蜜臀精品av| 最新日韩在线视频| 欧美一区二区三区在线| 日韩精品免费专区| 日韩影院免费视频| 视频在线在亚洲| 欧美国产日韩亚洲一区| 中文久久乱码一区二区| 日韩一级在线观看| 在线播放91灌醉迷j高跟美女| 色婷婷激情综合| jlzzjlzz亚洲女人18| 国产精品一色哟哟哟| 国产在线播放一区二区三区| 日本不卡不码高清免费观看| 香港成人在线视频| 午夜天堂影视香蕉久久| 午夜在线成人av| 婷婷夜色潮精品综合在线| 日日噜噜夜夜狠狠视频欧美人 | 精品一区二区国语对白| 日本成人超碰在线观看| 国产成人精品免费网站| 国产精品亚洲视频| 成人国产精品免费网站| 99久久精品国产观看| bt7086福利一区国产| 色综合一个色综合| 欧美私模裸体表演在线观看| 欧美日韩高清一区二区| 日韩欧美成人午夜| 久久精品男人的天堂| 国产精品久久国产精麻豆99网站| 亚洲人xxxx| 午夜精品久久久久久久久| 日本不卡123| 国产一区91精品张津瑜| 99精品国产一区二区三区不卡| 91污片在线观看| 欧美日韩美女一区二区| 欧美成人性福生活免费看| 欧美激情一区二区三区不卡| 有坂深雪av一区二区精品| 午夜精品福利视频网站| 国产在线不卡一区| 91黄色免费版| 日韩精品影音先锋| 中文字幕巨乱亚洲| 亚洲国产另类精品专区| 精品一区二区在线视频| 99精品在线免费| 91精品国产手机| 中文字幕第一页久久| 亚洲国产欧美在线| 国产一区二区三区四区在线观看 | 日韩丝袜美女视频| 中文字幕不卡一区| 日日夜夜一区二区| 成人丝袜18视频在线观看| 欧美日韩在线不卡| 国产精品天美传媒| 午夜精品123| av网站一区二区三区| 91麻豆精品国产91久久久更新时间| 久久久久久久综合日本| 亚洲国产日日夜夜| 成人综合婷婷国产精品久久蜜臀| 欧美日韩一区高清| 18欧美乱大交hd1984| 91高清视频免费看| 天堂va蜜桃一区二区三区漫画版| 一区二区三区在线观看视频| 久久er99精品| 欧美在线免费播放| 中文字幕欧美日韩一区| 日本成人在线视频网站| 国产亚洲精品久| 天天影视涩香欲综合网| www.欧美日韩| 久久午夜电影网| 日韩极品在线观看| 在线日韩国产精品| 国产精品丝袜黑色高跟| 蓝色福利精品导航| 欧美揉bbbbb揉bbbbb| 亚洲桃色在线一区| 国产激情偷乱视频一区二区三区| 91精品欧美一区二区三区综合在| 中文字幕一区二区三区视频| 国产精品 欧美精品| 日韩一区二区三区免费看| 亚洲成人动漫av| 日本高清不卡视频| 一区在线中文字幕| 丰满放荡岳乱妇91ww| 久久综合精品国产一区二区三区| 麻豆免费看一区二区三区| 欧美日韩国产首页在线观看| 久久久99精品久久| 99re这里只有精品首页| 喷白浆一区二区| 色偷偷久久一区二区三区| 国产精品国产三级国产专播品爱网| 狠狠色丁香久久婷婷综合_中| 欧美一区二区久久久| 视频一区二区中文字幕| 欧亚一区二区三区| 亚洲美女屁股眼交3| 99re在线精品| 一区二区视频在线| 91色.com| 亚洲精选视频免费看| 色综合欧美在线视频区| 亚洲人午夜精品天堂一二香蕉| 99久久久国产精品免费蜜臀| 国产精品免费免费| 不卡一区二区中文字幕| 亚洲欧美综合色| 91麻豆国产精品久久| 国产精品久久久久一区二区三区共| 成人精品小蝌蚪| 亚洲精品午夜久久久| 色婷婷av一区| 亚洲一区二区三区三| 欧美电影一区二区| 国产自产视频一区二区三区| 国产亚洲欧洲997久久综合 | 国产免费久久精品| 成人激情动漫在线观看| 亚洲人成亚洲人成在线观看图片| 色婷婷综合在线| 日韩不卡手机在线v区| 欧美va天堂va视频va在线| 国产激情精品久久久第一区二区 | 亚洲精品久久久蜜桃| 欧美美女直播网站| 精品一区二区精品| 亚洲欧美在线观看| 欧美三级电影一区| 国产精品伊人色| 一区二区三区日本| 日韩一区二区三区四区| 99re亚洲国产精品| 免费一级欧美片在线观看| 欧美激情一区二区三区四区| 在线观看免费视频综合| 激情图片小说一区| 亚洲欧美成aⅴ人在线观看| 欧美福利电影网| 国产精品亚洲午夜一区二区三区| 亚洲蜜桃精久久久久久久| 欧美大片在线观看一区二区| 成人高清视频免费观看| 日韩av中文在线观看| 欧美国产1区2区| 91精品婷婷国产综合久久性色| 国产精品一级在线| 亚洲第一福利视频在线| 久久久久国产精品麻豆| 欧美日韩成人高清| 大尺度一区二区| 天堂蜜桃一区二区三区| 成人免费在线视频| 精品成人一区二区三区| 欧美专区亚洲专区| 国产成人在线观看免费网站| 婷婷开心激情综合| 亚洲精品高清视频在线观看| 久久婷婷久久一区二区三区| 欧美日韩国产一级片| 91在线porny国产在线看| 狠狠色狠狠色合久久伊人| 亚洲国产综合人成综合网站| 国产精品久久久久一区二区三区 | 欧美日韩日日夜夜| av亚洲精华国产精华|