Novice initial examination, but also please the road Master a lot of guidance.
The program source code is as follows:
<?php
$conn = mysql_connect ("localhost", "root", "") or Die ("wrong!");
$sel =mysql_select_db ("MyDB", $conn);
$sql = "INSERT into ' mydb '. ' Test ' (
' ID ',
' UID ',
' RegDate ',
' Remark '
)
VALUES (
', ' php200 ', now (), ' dddd '
) ";
$que =mysql_query ($sql, $conn);
if ($que)
echo "true";
Else
echo "wrong";
?>
The mysql_connect () function opens a non-persistent MySQL connection.
Grammar
Mysql_connect (Server,user,pwd,newlink,clientflag)
| parameters |
Description |
| server |
Optional. Specify the server to connect to. Can include a port number, such as "Hostname:port", or a path to a local socket, such as ":/path/to/socket" for localhost. If the PHP directive mysql.default_host not defined (by default), the default value is ' localhost:3306 '. |
| user |
is optional. User name. The default value is the user name of the server process owner. |
| pwd |
is optional. Password. The default value is a blank password. |
| newlink |
is optional. If mysql_connect () is invoked the second time with the same argument, no new connection will be established, and the connection ID that is already open will be returned. The parameter New_link changes this behavior and causes mysql_connect () to always open a new connection, even when mysql_connect () was previously invoked with the same parameters. |
| clientflag |
Optional. The Client_flags parameter can be a combination of the following constants:
Mysql_client_ssl-using SSL encryption
- Mysql_c Lient_compress-Use the compression protocol
- Mysql_client_ignore_space-Allow the interval after the function name
- mysql_client_interactive-Allow off Interaction timeout before a closed connection time inactive
|
return value
If successful, returns a MySQL connection identity and returns FALSE if it fails.