<?php $hostname_contact_conn = "127.0.0.1"; $database_contact_conn = "guestbook"; $username_contact_conn = "user"; $password_contact_conn = "123456"; $contact_conn = mysql_pconnect($hostname_contact_conn, $username_contact_conn, $password_contact_conn) or trigger_error(mysql_error(),E_USER_ERROR);
$db_selected = mysql_select_db ('test' , $contact_conn ) or die ( 'Can\'t use the database : ' . mysql_error() ) ;
mysql_query('SET NAMES utf8'); mysql_query('SET CHARACTER_SET_CLIENT=utf8'); mysql_query('SET CHARACTER_SET_RESULTS=utf8');
session_start() ; // php.ini 內的 output_buffering 要設成 4096,以免產生錯誤
// echo $_REQUEST['guest_name'] . "<br />" ;
if( $_REQUEST['guest_name'] ) { /* $link = mysql_connect(dbhost, dbuser, dbpassword) or die("<b>error</b>: failed to connect to database"); */ $query = "SELECT email, comment FROM guestbook WHERE name='" . $_REQUEST['guest_name'] . "'" ; $result = mysql_query($query) or die("<b>error</b>: failed to execute query <i>$query</i>");
mysql_close($contact_conn);
$desiredContent = mysql_fetch_array($result, MYSQL_ASSOC);
mysql_free_result($result);
print "guest_email=$desiredContent[email]&guest_comment=$desiredContent[comment]" ; } ?>
|