ballhogjoni Posted January 5, 2007 Share Posted January 5, 2007 This is the error I get: Parse error: syntax error, unexpected $end in /home/realfina/public_html/signup=/article_cash/test.php on line 28<?php$username="xxxxxxxxx";$password="xxxxxxxxxxx";$database="xxxxxxxx";$mysqli = mysqli_connect("localhost","$username","$password","$database");if (mysqli_conect_errno()) { printf("connect failed:%s\n", mysqli_connect_error()); exit();} else { $sql = "SELECT TOP 1 * FROM xxxxxxxxx ORDER BY ID DESC"; $res = mysqli_query($mysqli, $sql); if ($res) { while ($newArray = mysqli_fetch_array($res, MYSQLI_ASSOC)) { $id = $newArray['id']; $testfield = $newArray['testfield']; echo "The Id is ".$id." and the text is ".$testfield."<br>; }} else { printf(Could not retrieve records: %s\n, mysqli_error($mysqli));}}mysqli_free_result($res);mysqli_close($mysqli);?> Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted January 5, 2007 Share Posted January 5, 2007 I'm surprised that is the only syntax error you're getting since you don't have any quotes deliminating the string in this line:[code]<?php printf(Could not retrieve records: %s\n, mysqli_error($mysqli));?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
ballhogjoni Posted January 5, 2007 Author Share Posted January 5, 2007 I was actually getting an error when I put the quotes in this lineprintf("Could not retrieve records: %sn", mysqli_error($mysqli)); Quote Link to comment Share on other sites More sharing options...
simcoweb Posted January 5, 2007 Share Posted January 5, 2007 It should work if you change this line as follows:echo "The Id is $id and the text is $testfield"; Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted January 5, 2007 Share Posted January 5, 2007 simcoweb's correction will solve the parse error (the original line of code had one double-quote after the last variable.)Because of the misplaced ; after the echo line in the post, I suspect that your code has a [b]"< br / >"[/b] (without the spaces) but that the final double-quote on this is missing. This < br / > caused the newline in the post because the code was not enclosed in [ CODE ] tags. Posting this in [ CODE ] tags also would have helped find the problem as the color highlighting would have pointed out the missing quote.The next problem, as kenrbnsn pointed out, would be the missing quotes in the printf(...) statement. Quote Link to comment 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.