Wed- Wed-
-33
. .____________
..___________
__________
__________
2013
: Wed- Wed-
, , .
PHP.
:
1) :
PHP .
PHP : Oracle, Adabas D, Sybase, FilePro, mSQL, Velocis, MySQL, Informix, Solid, dBase, ODBC, Unix dbm, PostgreSQL. . MySQL.
mysql_connect: $connect = mysql_connect(<>, <>, <>); , mysql- root, localhost-, , mysql. ! " localhost-" , PHP, .
, php . , , . $connect - , . ,
-
, : ( ) , :
$result = mysql_db_query(string , string [, ]);
$result = mysql_query(string [, ]);
mysql_query, , :
mysql_select_db(string );
$result. . . mysql_fetch_row mysql_fetch_array:
echo "<table>";
while ($row = mysql_fetch_array($result))
echo "<tr><td>", $row["field1"], "</td><td>", $row["field2"], "</td></tr>";
echo "</table>";
mysql_fetch_array ( $row) , - (, table.field, field). mysql_fetch_row , - , 0.
|
|
, .. , (, , ), mysql_fetch_array. -- , , mysql_fetch_row - .
-
DELETE UPDATE. - mysql_query (mysql_db_query). :
$result = mysql_query("SELECT * FROM sometable");
mysql_query("DELETE FROM sometable WHERE id=...");
, - , .
mysql_error:
echo " . MySQL :", mysql_error();
, :
$result = mysql_query($request);
if (!$result)
echo " . MySQL :", mysql_error();
else {
echo "<table>";
while ($row = mysql_fetch_array($result))
echo "<tr><td>", $row["field1"], "</td><td>", $row["field2"], "</td></tr>";
echo "</table>";
};
, :
$request = "UPDATE (...)";
mysql_query($request);
if (!mysql_error())
echo " !";
else echo " . MySQL :", mysql_error();
, ( , , ).
2) cookie
cookies . . cookies , .
:
●
●
●
session_start, PHP-:
session_start();
, , , , . , .
- $_SESSION. index.php $_SESSION .
<?php
//
session_start();
//
$_SESSION['name'] = "value";
//
|
|
$arr = array("first", "second", "third");
$_SESSION['arr'] = $arr;
//
echo "<a href='other.php'> </a>";
?>
, unset():
unset($_SESSION ["username"] );
Cookies - , , "-", URL, cookies .
cookies
cookies setcookie:
Setcookie
bool setcookie (string name [, string value [, int expire [, string path
[, string domain [, int secure]]]]])
:
● name - cookie;
● value - , cookie $name;
● expire - , cookie ;
● path - , cookie;
● domain - , cookie;
● secure - , , cookie HTTPS. 0, cookie HTTP.
cookies , , cookie - , cookies . cookies - , , .