pinochio Posted September 29, 2009 Share Posted September 29, 2009 I introduced all variables but when I run it it says this: Parse error: syntax error, unexpected T_VARIABLE in c:\program files\apache group\Apache\htdocs\CT\showguestbook.php on line 8 Any ideas what might be wrong? <?php $DBConnect = @mysqli_connect("root", "", "") or die("<p>Unable to connect to the databse server.</p>" . "<p>Error code " . mysqli_connect_errno() . ":" . mysqli_connect_error()) . "</p>" $DBName = "guestbook"; if (!@mysqli_select_db($DBConnect, $DBName)) die("<p>Ooooops there are no entries...</p>"); $TableName = "visitors"; $SQLstring = "SELECT * FROM $TableName"; $QueryResult = @mysqli_query($DBConnect, $SQLString); if(mysqli_num_rows($QueryResult) == 0) die("<p>Oooops there are no entries...</p>"; echo "<p>The following visitors have signed our guestbook:</p>"; echo "<table width='100%' border='1'>"; echo "<tr><th>Guest Name</th><th>Guest Email</th></tr>"; $Row = mysqli_fetch_assoc($QueryResult); do { echo "<tr><td>($Row['Name'])</td></tr>"; echo "<tr><td>($Row['Email'])</td></tr>"; $Row = mysqli_fetch_assoc($QueryResult); } while ($Row); mysqli_free_result($QueryResult); mysqli_close($DBConnect); ?> Link to comment https://forums.phpfreaks.com/topic/175897-solved-parse-error/ Share on other sites More sharing options...
Garethp Posted September 29, 2009 Share Posted September 29, 2009 Look at the top <?php $DBConnect = @mysqli_connect("root", "", "") or die("<p>Unable to connect to the databse server.</p>" . "<p>Error code " . mysqli_connect_errno() . ":" . mysqli_connect_error()) . "</p>" . ":" . mysqli_connect_error()) . "</p>" Should be . ":" . mysqli_connect_error()) . "</p>"); Link to comment https://forums.phpfreaks.com/topic/175897-solved-parse-error/#findComment-926865 Share on other sites More sharing options...
pinochio Posted September 29, 2009 Author Share Posted September 29, 2009 Still the same problem........ Link to comment https://forums.phpfreaks.com/topic/175897-solved-parse-error/#findComment-926867 Share on other sites More sharing options...
Garethp Posted September 29, 2009 Share Posted September 29, 2009 Try taking mysqli_connect_error()) and replacing it with mysqli_connect_error() Link to comment https://forums.phpfreaks.com/topic/175897-solved-parse-error/#findComment-926871 Share on other sites More sharing options...
redarrow Posted September 29, 2009 Share Posted September 29, 2009 try this please.... <?php $DBConnect = @mysqli_connect("root", "", "") or die("<p>Unable to connect to the databse server.</p>" . "<p>Error code " . mysqli_connect_errno() . ":" . mysqli_connect_error()) . "</p>"; $DBName = "guestbook"; if (!@mysqli_select_db($DBConnect, $DBName)) die("<p>Ooooops there are no entries...</p>"); $TableName = "visitors"; $SQLstring = "SELECT * FROM $TableName"; $QueryResult = @mysqli_query($DBConnect, $SQLString); if(mysqli_num_rows($QueryResult) == 0) die("<p>Oooops there are no entries...</p>"); echo "<p>The following visitors have signed our guestbook:</p>"; echo "<table width='100%' border='1'>"; echo "<tr><th>Guest Name</th><th>Guest Email</th></tr>"; $Row = mysqli_fetch_assoc($QueryResult); do { echo "<tr><td>{$Row['Name']}</td></tr>"; echo "<tr><td>{$Row['Email']}</td></tr>"; $Row = mysqli_fetch_assoc($QueryResult); } while ($Row); mysqli_free_result($QueryResult); mysqli_close($DBConnect); ?> Link to comment https://forums.phpfreaks.com/topic/175897-solved-parse-error/#findComment-926872 Share on other sites More sharing options...
pinochio Posted September 29, 2009 Author Share Posted September 29, 2009 Parse error: syntax error, unexpected T_VARIABLE in c:\program files\apache group\Apache\htdocs\CT\showguestbook.php on line 8 It says that the problem is on line 8, but line 8 looks absolutely normal.... Thank for your help! Link to comment https://forums.phpfreaks.com/topic/175897-solved-parse-error/#findComment-926874 Share on other sites More sharing options...
Calver Posted September 29, 2009 Share Posted September 29, 2009 Hello, $SQLstring and $SQLString are different ... Link to comment https://forums.phpfreaks.com/topic/175897-solved-parse-error/#findComment-926878 Share on other sites More sharing options...
redarrow Posted September 29, 2009 Share Posted September 29, 2009 you must be careful when typing variables pal... most common problem that is... remember most programmers use this RedArrow use of uppercase first letter then uppercase the next word first letter.... get into this kind off habit best practice... Link to comment https://forums.phpfreaks.com/topic/175897-solved-parse-error/#findComment-926882 Share on other sites More sharing options...
pinochio Posted September 29, 2009 Author Share Posted September 29, 2009 It is working thank you very much!!!! Link to comment https://forums.phpfreaks.com/topic/175897-solved-parse-error/#findComment-926884 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.