IceDragon Posted July 30, 2008 Share Posted July 30, 2008 I keep getting Parse error: parse error, unexpected $ in /home/www/mywebsite.com/log.php on line 38 line 38 is the last line of log.php (</html>) and I don't have a clue why I keep getting an error.. log.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Logs 2</title> </head> <body> <?php // DATABASE INFORMATION $user="myusername"; $host="myhost"; $password="mypass"; $database="mydb"; // CONNECTING TO YOUR DATABASE $connection = mysql_connect($host,$user,$password) or die ("Couldn't connect to server"); $db = mysql_select_db($database,$connection) or die ("Couldn't select database"); // GETTING THE VISITOR INFORMATION FROM YOUR TABLE $query = mysql_query("SELECT * FROM Log ORDER BY ID DESC"); // GETS AND DISPLAYS THE ROWS IN YOUR TABLE while ( $row = mysql_fetch_array($query) ) { $id = $row['ID']; $date = $row['Datum']; $ip = $row['IP']; $lang = $row['Jezik']; $referer = $row['Referer']; $browser = $row['Browser']; $currentURL = $row['Trenutni URL']; ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/117346-parse-error-unexpected/ Share on other sites More sharing options...
unkwntech Posted July 30, 2008 Share Posted July 30, 2008 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Logs 2</title> </head> <body> <?php // DATABASE INFORMATION $user="myusername"; $host="myhost"; $password="mypass"; $database="mydb"; // CONNECTING TO YOUR DATABASE $connection = mysql_connect($host,$user,$password) or die ("Couldn't connect to server"); $db = mysql_select_db($database,$connection) or die ("Couldn't select database"); // GETTING THE VISITOR INFORMATION FROM YOUR TABLE $query = mysql_query("SELECT * FROM Log ORDER BY ID DESC"); // GETS AND DISPLAYS THE ROWS IN YOUR TABLE while ( $row = mysql_fetch_array($query) ) { $id = $row['ID']; $date = $row['Datum']; $ip = $row['IP']; $lang = $row['Jezik']; $referer = $row['Referer']; $browser = $row['Browser']; $currentURL = $row['Trenutni URL']; } //<----------RIght Here ?> </body> </html> You forgot to close your loop. Quote Link to comment https://forums.phpfreaks.com/topic/117346-parse-error-unexpected/#findComment-603603 Share on other sites More sharing options...
IceDragon Posted July 30, 2008 Author Share Posted July 30, 2008 ok thanks. I have another problem now.. I get a the mysql_query() error on line 27.. while ( $row = mysql_fetch_array($query) ) i added the 'or die(mysql_error());' to that line.. and now I get the Table 'mydbusername.Log' doesn't exist here's the sql file.. CREATE TABLE `Log` ( `ID` int( NOT NULL auto_increment, `Datum` datetime NOT NULL default '0000-00-00 00:00:00', `IP` varchar(20) NOT NULL default '', `Jezik` varchar (20) NOT NULL default '', `Referer` varchar(255) NOT NULL default '', `Browser` varchar(255) NOT NULL default '', `Trenutni URL` varchar (255) NOT NULL default '', PRIMARY KEY (`ID`) ) Quote Link to comment https://forums.phpfreaks.com/topic/117346-parse-error-unexpected/#findComment-603627 Share on other sites More sharing options...
IceDragon Posted July 30, 2008 Author Share Posted July 30, 2008 i meant to ask why doesn't it exist/what have i missed.. I can post the other php code related to this if it helps. Edit: the other code: <?php $user="myusername"; $host="myhost"; $password="mypass"; $database="mydb"; $connection = mysql_connect($host,$user,$password) or die ("Couldn't connect to server"); $db = mysql_select_db($database,$connection) or die ("Couldn't select database"); $ip = $_SERVER['REMOTE_ADDR']; $lang = $_SERVER['HTTP_ACCEPT_LANGUAGE']; $referer = $_SERVER['HTTP_REFERER']; $browser = $_SERVER['HTTP_USER_AGENT']; $currentURL = $_SERVER['REQUEST_URI']; $query = mysql_query("INSERT INTO Log VALUES ('',now(),'$ip',$lang','$referer','$browser','$currentURL')"); Quote Link to comment https://forums.phpfreaks.com/topic/117346-parse-error-unexpected/#findComment-603655 Share on other sites More sharing options...
paul2463 Posted July 30, 2008 Share Posted July 30, 2008 add the or die bit to the query string and see what that rings up $query = mysql_query("SELECT * FROM Log ORDER BY ID DESC") or die ("error in query" . mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/117346-parse-error-unexpected/#findComment-603744 Share on other sites More sharing options...
sasa Posted July 30, 2008 Share Posted July 30, 2008 try $query = mysql_query("SELECT * FROM `Log` ORDER BY ID DESC") or die ("error in query" . mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/117346-parse-error-unexpected/#findComment-603759 Share on other sites More sharing options...
IceDragon Posted July 30, 2008 Author Share Posted July 30, 2008 I get Table 'mydbusername.Log' doesn't exist Quote Link to comment https://forums.phpfreaks.com/topic/117346-parse-error-unexpected/#findComment-603790 Share on other sites More sharing options...
revraz Posted July 30, 2008 Share Posted July 30, 2008 Well verify the Table does in fact exist? Quote Link to comment https://forums.phpfreaks.com/topic/117346-parse-error-unexpected/#findComment-603794 Share on other sites More sharing options...
paul2463 Posted July 30, 2008 Share Posted July 30, 2008 this might seem a silly question but is the database you are trying to connect to called "mydbusername" or have you just not remembered to reset it to what the database is called???? or have you changed that bit for this forum?? Quote Link to comment https://forums.phpfreaks.com/topic/117346-parse-error-unexpected/#findComment-603797 Share on other sites More sharing options...
IceDragon Posted July 30, 2008 Author Share Posted July 30, 2008 I've changed it for this forum. Quote Link to comment https://forums.phpfreaks.com/topic/117346-parse-error-unexpected/#findComment-603799 Share on other sites More sharing options...
paul2463 Posted July 30, 2008 Share Posted July 30, 2008 then you have connected to the wrong database or the table does not in fact exist, i know oyu have posted the create table code, but has it been created inside the database you are calling it from? Quote Link to comment https://forums.phpfreaks.com/topic/117346-parse-error-unexpected/#findComment-603802 Share on other sites More sharing options...
IceDragon Posted July 30, 2008 Author Share Posted July 30, 2008 ahh I got it now. Yea I forgot to create it inside the database. But now when I load the page where tables were supposed to be I just get a blank page.. (and yeah I've added the HTML part that wasn't included in previous posts insde php tags) Quote Link to comment https://forums.phpfreaks.com/topic/117346-parse-error-unexpected/#findComment-603808 Share on other sites More sharing options...
revraz Posted July 30, 2008 Share Posted July 30, 2008 We would need to see that code in order to help you. Quote Link to comment https://forums.phpfreaks.com/topic/117346-parse-error-unexpected/#findComment-603810 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.