gwolff2005 Posted April 24, 2009 Share Posted April 24, 2009 Hi guys, I get the error Parse error: syntax error, unexpected T_STRING in this codeline. mysql_query($query) or die("There was a mysql error<br />Query: {$query}<br />Error Returned: " . mysql_error()); Can you please tell me what is wrong? Quote Link to comment https://forums.phpfreaks.com/topic/155537-solved-parse-error-syntax-error-unexpected-t_string/ Share on other sites More sharing options...
Mchl Posted April 24, 2009 Share Posted April 24, 2009 Probably missing ; in the line before Quote Link to comment https://forums.phpfreaks.com/topic/155537-solved-parse-error-syntax-error-unexpected-t_string/#findComment-818498 Share on other sites More sharing options...
Maq Posted April 24, 2009 Share Posted April 24, 2009 Mchl is most likely correct, but show more of the surrounding code. Quote Link to comment https://forums.phpfreaks.com/topic/155537-solved-parse-error-syntax-error-unexpected-t_string/#findComment-818500 Share on other sites More sharing options...
Mchl Posted April 24, 2009 Share Posted April 24, 2009 Could be as well unpaired " somewhere before. Quote Link to comment https://forums.phpfreaks.com/topic/155537-solved-parse-error-syntax-error-unexpected-t_string/#findComment-818502 Share on other sites More sharing options...
gwolff2005 Posted April 24, 2009 Author Share Posted April 24, 2009 Thanks you three! Yeah mchl was right. Now I got another problem. I really wanna get this code now done.. but still it says there is an error. Hope you can help me! Parse error: syntax error, unexpected '}', expecting ',' or ';' in /home/guntmar/public_html/passiontest.php on line 175 <?php require_once('Connections/Login.php'); ?> <?php session_start(); ?> <?php //You will need to update all the below variables $mysqlhost = "localhost"; $mysqluser = "guntmar"; $mysqlpass = "je20sa05"; $mysqldb = "guntmar"; $mysqltable = "users"; $username = "username"; // End Variables mysql_connect($mysqlhost, $mysqluser, $mysqlpass); mysql_select_db($mysqldb); $query = "SELECT * FROM " . $mysqltable . " WHERE username='" . $username . "'"; $result = mysql_query($query) or die("There was a mysql error"); while($row = mysql_fetch_array($result)){ $currentpo = $row['resultspo']; $currentmo = $row['resultsmo']; } function showForm () { echo <<<SHOWFORM <form id="form1" name="form1" method="post" action=""> <table width="699" border="0" align="center" cellspacing="5" class="style1"> <tr> <td colspan="3"><div align="center"><span class="style4">Your Passion Test</span></div></td> </tr> <tr> <td width="24"> </td> <td width="429"> </td> <td width="220"><div align="right">Saturday, 03/28/09</div></td> </tr> <tr> <td> </td> <td> </td> <td><div align="right">$_SESSION[MM_firstname]</div></td> </tr> <tr> <td> </td> <td> </td> <td><div align="right"></div></td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>1</td> <td><strong>I like talking to people. </strong><br /> </b></td> <td><div align="left"> <input name="po1" type="radio" value="0" /> 0 <input name="po1" type="radio" value="1" /> 1 <input name="po1" type="radio" value="2" /> 2 <input name="po1" type="radio" value="3" /> 3 <input name="po1" type="radio" value="4" /> 4 <input name="po1" type="radio" value="5" /> 5</div></td> </tr> <tr> <td>2</td> <td>It is important for me what other people think. </td> <td><p> <label></label> <label></label> <input name="mo2" type="radio" value="0" /> 0 <input name="mo2" type="radio" value="1" /> 1 <input name="mo2" type="radio" value="2" /> 2 <input name="mo2" type="radio" value="3" /> 3 <input name="mo2" type="radio" value="4" /> 4 <input name="mo2" type="radio" value="5" /> 5<br /> <br /> </p></td> </tr> <tr> <td>3</td> <td class="style1">My level of excitement is high right now. </td> <td><p> <label></label> <input name="mo3" type="radio" value="0" /> 0 <input name="mo3" type="radio" value="1" /> 1 <input name="mo3" type="radio" value="2" /> 2 <input name="mo3" type="radio" value="3" /> 3 <input name="mo3" type="radio" value="4" /> 4 <input name="mo3" type="radio" value="5" /> 5<br /> </p></td> </tr> <tr> <td>4</td> <td>I like solving mathematical tasks. </td> <td><input name="po4" type="radio" value="0" /> 0 <input name="po4" type="radio" value="1" /> 1 <input name="po4" type="radio" value="2" /> 2 <input name="po4" type="radio" value="3" /> 3 <input name="po4" type="radio" value="4" /> 4 <input name="po4" type="radio" value="5" /> 5</td> </tr> </table> <p align="center"> <input name="Submit" type="submit" class="style1" value="go on" /> </p> </form> SHOWFORM; }//Close showForm() ?> <!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=iso-8859-1" /> <title>Your Passion Test</title> <style type="text/css"> <!-- .style1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight: bold; color: #000033; } .style3 {font-family: Verdana, Arial, Helvetica, sans-serif} .style4 { font-size: 20px; color: #996600; } --> </style> </head> <body> <?php if (!isset($_POST['Submit'])) { showForm(); } else { $pagepo = ($_POST['po1'] + $_POST['po4']); $pagemo = ($_POST['mo2'] + $_POST['mo3']); $newpo = ($currentpo + $pagepo); $newmo = ($currentmo + $pagemo); } $query = "UPDATE ".$mysqltable." SET resultspo = '".$newpo."', resultsmo = '".$newmo."' WHERE username = '".$username."' AND id = '".$_SESSION['id']."'"; mysql_query($query) or die("There was a mysql error<br />Query: {$query}<br />Error Returned: " . mysql_error()); //JavaScript page redirect... echo '<script>location.href="passiontest2.php"</script>' } // Close if/else ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/155537-solved-parse-error-syntax-error-unexpected-t_string/#findComment-818510 Share on other sites More sharing options...
jonsjava Posted April 24, 2009 Share Posted April 24, 2009 I think I put your code in the write place. You had an extra } in line 175ish. <?php require_once('Connections/Login.php'); ?> <?php session_start(); ?> <?php //You will need to update all the below variables $mysqlhost = "localhost"; $mysqluser = "guntmar"; $mysqlpass = "je20sa05"; $mysqldb = "guntmar"; $mysqltable = "users"; $username = "username"; // End Variables mysql_connect($mysqlhost, $mysqluser, $mysqlpass); mysql_select_db($mysqldb); $query = "SELECT * FROM " . $mysqltable . " WHERE username='" . $username . "'"; $result = mysql_query($query) or die("There was a mysql error"); while($row = mysql_fetch_array($result)){ $currentpo = $row['resultspo']; $currentmo = $row['resultsmo']; } function showForm () { echo <<<SHOWFORM <form id="form1" name="form1" method="post" action=""> <table width="699" border="0" align="center" cellspacing="5" class="style1"> <tr> <td colspan="3"><div align="center"><span class="style4">Your Passion Test</span></div></td> </tr> <tr> <td width="24"> </td> <td width="429"> </td> <td width="220"><div align="right">Saturday, 03/28/09</div></td> </tr> <tr> <td> </td> <td> </td> <td><div align="right">$_SESSION[MM_firstname]</div></td> </tr> <tr> <td> </td> <td> </td> <td><div align="right"></div></td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>1</td> <td><strong>I like talking to people. </strong><br /> </b></td> <td><div align="left"> <input name="po1" type="radio" value="0" /> 0 <input name="po1" type="radio" value="1" /> 1 <input name="po1" type="radio" value="2" /> 2 <input name="po1" type="radio" value="3" /> 3 <input name="po1" type="radio" value="4" /> 4 <input name="po1" type="radio" value="5" /> 5</div></td> </tr> <tr> <td>2</td> <td>It is important for me what other people think. </td> <td><p> <label></label> <label></label> <input name="mo2" type="radio" value="0" /> 0 <input name="mo2" type="radio" value="1" /> 1 <input name="mo2" type="radio" value="2" /> 2 <input name="mo2" type="radio" value="3" /> 3 <input name="mo2" type="radio" value="4" /> 4 <input name="mo2" type="radio" value="5" /> 5<br /> <br /> </p></td> </tr> <tr> <td>3</td> <td class="style1">My level of excitement is high right now. </td> <td><p> <label></label> <input name="mo3" type="radio" value="0" /> 0 <input name="mo3" type="radio" value="1" /> 1 <input name="mo3" type="radio" value="2" /> 2 <input name="mo3" type="radio" value="3" /> 3 <input name="mo3" type="radio" value="4" /> 4 <input name="mo3" type="radio" value="5" /> 5<br /> </p></td> </tr> <tr> <td>4</td> <td>I like solving mathematical tasks. </td> <td><input name="po4" type="radio" value="0" /> 0 <input name="po4" type="radio" value="1" /> 1 <input name="po4" type="radio" value="2" /> 2 <input name="po4" type="radio" value="3" /> 3 <input name="po4" type="radio" value="4" /> 4 <input name="po4" type="radio" value="5" /> 5</td> </tr> </table> <p align="center"> <input name="Submit" type="submit" class="style1" value="go on" /> </p> </form> SHOWFORM; }//Close showForm() ?> <!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=iso-8859-1" /> <title>Your Passion Test</title> <style type="text/css"> <!-- .style1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight: bold; color: #000033; } .style3 {font-family: Verdana, Arial, Helvetica, sans-serif} .style4 { font-size: 20px; color: #996600; } --> </style> </head> <body> <?php if (!isset($_POST['Submit'])) { showForm(); } else { $pagepo = ($_POST['po1'] + $_POST['po4']); $pagemo = ($_POST['mo2'] + $_POST['mo3']); $newpo = ($currentpo + $pagepo); $newmo = ($currentmo + $pagemo); $query = "UPDATE ".$mysqltable." SET resultspo = '".$newpo."', resultsmo = '".$newmo."' WHERE username = '".$username."' AND id = '".$_SESSION['id']."'"; mysql_query($query) or die("There was a mysql error<br />Query: {$query}<br />Error Returned: " . mysql_error()); //JavaScript page redirect... echo '<script>location.href="passiontest2.php"</script>'; } // Close if/else ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/155537-solved-parse-error-syntax-error-unexpected-t_string/#findComment-818513 Share on other sites More sharing options...
Mchl Posted April 24, 2009 Share Posted April 24, 2009 Here's a link that you miight find helpful http://www.phpfreaks.com/tutorial/debugging-a-beginners-guide/page1 Also, consider using an IDE which will find such errors for you. Quote Link to comment https://forums.phpfreaks.com/topic/155537-solved-parse-error-syntax-error-unexpected-t_string/#findComment-818517 Share on other sites More sharing options...
jonsjava Posted April 24, 2009 Share Posted April 24, 2009 Zend is nice, but Eclipse does just fine (and it's free!) Quote Link to comment https://forums.phpfreaks.com/topic/155537-solved-parse-error-syntax-error-unexpected-t_string/#findComment-818518 Share on other sites More sharing options...
Mchl Posted April 24, 2009 Share Posted April 24, 2009 And NetBeans rocks if you ask me. Quote Link to comment https://forums.phpfreaks.com/topic/155537-solved-parse-error-syntax-error-unexpected-t_string/#findComment-818521 Share on other sites More sharing options...
Maq Posted April 24, 2009 Share Posted April 24, 2009 And NetBeans rocks if you ask me. I agree with Netbeans, but Eclipse is also one of my favorites. They are pretty similar. Quote Link to comment https://forums.phpfreaks.com/topic/155537-solved-parse-error-syntax-error-unexpected-t_string/#findComment-818525 Share on other sites More sharing options...
gwolff2005 Posted April 24, 2009 Author Share Posted April 24, 2009 Hi guys thank you so mcuh for your help. It shows now the text but now it seems it is in a loop... I hop you can help me with that... Please I will ppost it unfder another topic.. Quote Link to comment https://forums.phpfreaks.com/topic/155537-solved-parse-error-syntax-error-unexpected-t_string/#findComment-818527 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.