ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Hack:   Installing the MySQL Database
Subject:   parsing error
Date:   2003-10-11 15:14:51
From:   simjh
I am new to mysql, trying to install it and am getting this error message:


Parse error: parse error, unexpected T_PRINT in /Users/simjh/Sites/test.php on line 2


attached is my test.php file:


1 <?
2 print "<pre>";
3
4 // log into our local server using the mysql root user.
5 &dbh = mysql_connect( "localhost", "root", "");
6
7
8 // select the 'test' database created during installation.
9 mysql_select_db( "test" ) or die ( mysql_error() . "\n" );
10 print "Connection to the database has been established. \n";
11
12
13 // create a simplistic table.
14 $table = "CREATE table wisdom (
15 id int(4) PRIMARY KEY AUTO_INCREMENT,
16 wisdom char(255), author char(125) );";
17
18 $response = mysql_query( &table, &dbh ) );
19 if ($response) { print "The table was created correctly!\n"; }
20 esle { print mysql_error () . "\n"; }
21
22
23 //now, we'll add some data to our newly created table.
24 //to add different wisdom, just change the 'values'.
25 $INSERT_data = "INSERT into wisdom ( wisdom, author )
26 values ( 'Hello, World!', 'morbus' );";
27
28 $response = mysql_query( $INSERT_data, $dbh );
29 if ($response) { print "The data was INSERTed correctly!\n"; }
30 else { print mysql_error () . "\n"; }
31
32
33 //and read it back for printing purposes.
34 $get_table_data = "SELECT * FROM wisdom;";
35 $response = mysql_query( $get_table_data, $dbh );
36 if ($response) { print "We successfully got all the table data.\n"; }
37 else { print mysql_error () . "\n"; }
38
39
40 // now print it out for hte user.
41 while ( $one_line_of_data = mysql_fetch_array( $response ) ) {
42 extract ( $one_line_of_data );
43 print "#$id: $author sez: \"$wisdom\"\n";
44 }
45
46 print "";
47 ?>



Is there any there any way to fixt this? Thanks!