File: odbc-t2.php3

package info (click to toggle)
php3 3%3A3.0.18-0potato1.1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 17,736 kB
  • ctags: 11,198
  • sloc: ansic: 108,120; sh: 2,512; php: 2,024; yacc: 1,887; makefile: 1,038; perl: 537; pascal: 238; awk: 90; cpp: 28; sql: 11
file content (65 lines) | stat: -rw-r--r-- 1,604 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<HTML>
<HEAD>
<TITLE>Quick &amp; dirty ODBC test #2</TITLE>
</HEAD>
<BODY>
<H1>ODBC Test 2 - Create table</H1>
<?
if(isset($dbuser)){
?>
Connecting to <? echo $dsn; ?> as <? echo $dbuser; ?>
<?
$conn = odbc_connect($dsn,$dbuser,$dbpwd);
if (!$conn){
?>
<H2>Error connecting to database! Check DSN, username and password</H2>
<?
}else{
?>
- OK<p>
Dropping table "php3_test"
<?
Error_Reporting(0);
$res = odbc_exec($conn,"drop table php3_test");
if($res){
	odbc_free_result($res);
	$res = 0;
}
?>
- OK<p>
Create table "php3_test"
<?
error_reporting(1);
$res = odbc_exec($conn,"create table php3_test (a char(16), b integer, c float, d varchar(128))");
if($res){
	echo " - OK<p>Table Info:<br>";
	$info = odbc_exec($conn,"select * from php3_test");
	$numfields = odbc_num_fields($info);
	echo "<table><tr><th>Name</th><th>Type</th><th>Length</th></tr>\n";
	for($i=1;$i<=$numfields;$i++){
	printf("<tr><td>%s</td><td>%s</td><td>%s</td></tr>\n", odbc_field_name($info,$i),odbc_field_type($info,$i),odbc_field_len($info,$i));
	}
	echo "</table>";
?>
<p><HR width=50%"><p>
<A HREF="odbc-t3.php3<? echo "?dbuser=",$dbuser,"&dsn=",$dsn,"&dbpwd=",$dbpwd; ?>">Proceed to next test</A> 
| <A HREF="<? echo $PHP_SELF; ?>">Change login information</A>

<?
	}
    }
} else {
?>
<form action="odbc-t3.php3" method=post>
<table border=0>
<tr><td>Database (DSN): </td><td><input type=text name=dsn></td></tr>
<tr><td>User: </td><td><input type=text name=dbuser></td></tr>
<tr><td>Password: </td><td><input type=password name=dbpwd></td></tr>
</table>
<input type=submit value="Continue">

</form>
<? 
} ?>
</BODY>
</HTML>