1 |
dpavlin |
31 |
<?php |
2 |
|
|
|
3 |
|
|
/****************************************************************/ |
4 |
|
|
|
5 |
|
|
/* constants */ |
6 |
|
|
$DEBUG = 0; |
7 |
|
|
|
8 |
|
|
/****************************************************************/ |
9 |
|
|
|
10 |
|
|
/* database parameters */ |
11 |
|
|
$db_nam = "libdata"; |
12 |
|
|
$db_srv = "localhost"; |
13 |
|
|
$db_usr = "libdata"; |
14 |
|
|
$db_pwd = "libdatapw"; |
15 |
|
|
|
16 |
|
|
/****************************************************************/ |
17 |
|
|
|
18 |
|
|
/* establish a connection to the database or bailout */ |
19 |
|
|
$con = mysql_connect ( $db_srv, $db_usr, $db_pwd ) |
20 |
|
|
or die ( "ERROR: Could not connect to database server!" ); |
21 |
|
|
$result = mysql_select_db ( $db_nam, $con ) |
22 |
|
|
or die ( "ERROR: Could not connect to database!" ); |
23 |
|
|
|
24 |
|
|
/****************************************************************/ |
25 |
|
|
|
26 |
|
|
|
27 |
|
|
/* some useful functions */ |
28 |
|
|
|
29 |
|
|
/* return an error message from a failed sql query */ |
30 |
|
|
function sql_err ( $p_sql ) { |
31 |
|
|
printf ( "ERROR: Query failed.<br>%s<br>%s: %s<br>\n", |
32 |
|
|
$p_sql, mysql_errno(), mysql_error() ); |
33 |
|
|
return 1; |
34 |
|
|
} |
35 |
|
|
|
36 |
|
|
/* finish off the html stream and die */ |
37 |
|
|
function bailout() { |
38 |
|
|
die ( "Bailing Out!<br>\n</body></html>\n" ); |
39 |
|
|
} |
40 |
|
|
|
41 |
|
|
|
42 |
|
|
?> |