Whats wrong with this :S

  • Zackeriney
  • Graduate
  • Graduate
  • Zackeriney
  • Posts: 128

Post 3+ Months Ago

i have made this code and get the following error


Parse error: syntax error, unexpected $end in /home/x/public_html/z/1/test.php on line 26


code is:
PHP Code: [ Select ]
 
<!-- Close the table cell & row it is in -->
 
</td></tr>
 
</table>
 
</font>
 
<?php
 
 
 
$host = 'localhost';
 
$user = 'properuserhere';
 
$password = 'pswordhere';
 
 
 
$txt_db_name = 'dbname';
 
 
 
$connection = mysql_connect("$host","$user","$password")
 
or die(mysql_error());
 
mysql_select_db("$txt_db_name",$connection)
 
or die(mysql_error());
 
 
 
$updated_query = mysql_query("SELECT * FROM `tablename` WHERE 1;
 
or die(mysql_error());
 
 
 
$result = mysql_fetch_row($updated_query); echo $result[0];
 
?>
 
 
 
</BODY>
 
</HTML>
 
 
  1.  
  2. <!-- Close the table cell & row it is in -->
  3.  
  4. </td></tr>
  5.  
  6. </table>
  7.  
  8. </font>
  9.  
  10. <?php
  11.  
  12.  
  13.  
  14. $host = 'localhost';
  15.  
  16. $user = 'properuserhere';
  17.  
  18. $password = 'pswordhere';
  19.  
  20.  
  21.  
  22. $txt_db_name = 'dbname';
  23.  
  24.  
  25.  
  26. $connection = mysql_connect("$host","$user","$password")
  27.  
  28. or die(mysql_error());
  29.  
  30. mysql_select_db("$txt_db_name",$connection)
  31.  
  32. or die(mysql_error());
  33.  
  34.  
  35.  
  36. $updated_query = mysql_query("SELECT * FROM `tablename` WHERE 1;
  37.  
  38. or die(mysql_error());
  39.  
  40.  
  41.  
  42. $result = mysql_fetch_row($updated_query); echo $result[0];
  43.  
  44. ?>
  45.  
  46.  
  47.  
  48. </BODY>
  49.  
  50. </HTML>
  51.  
  52.  
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • dyefade
  • Expert
  • Expert
  • User avatar
  • Posts: 712
  • Loc: UK

Post 3+ Months Ago

You have an extra ?> (close tag) at the end - not sure if it's causing the problem, but it shouldn't be there anyway.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

What's missing from this line ?
PHP Code: [ Select ]
$updated_query  =  mysql_query("SELECT  *  FROM  `tablename`  WHERE  1;
 
or  die(mysql_error());
  1. $updated_query  =  mysql_query("SELECT  *  FROM  `tablename`  WHERE  1;
  2.  
  3. or  die(mysql_error());
  • Zackeriney
  • Graduate
  • Graduate
  • Zackeriney
  • Posts: 128

Post 3+ Months Ago

hi it didnt copy properly i dont think. this is the actual code

PHP Code: [ Select ]
 
 
 
<!-- Close the table cell & row it is in -->
 
</td></tr>
 
</table>
 
</font>
 
<?php
 
 
 
$host = 'localhost';
 
$user = 'user';
 
$password = 'pword';
 
 
 
$txt_db_name = 'db';
 
 
 
$connection = mysql_connect("$host","$user","$password")
 
or die(mysql_error());
 
mysql_select_db("$txt_db_name",$connection)
 
or die(mysql_error());
 
 
 
$updated_query = mysql_query(SELECT * FROM comments1)
 
 
 
$result = mysql_fetch_row($updated_query); echo $result[0];
 
</BODY>
 
</HTML>
 
?>
 
 
  1.  
  2.  
  3.  
  4. <!-- Close the table cell & row it is in -->
  5.  
  6. </td></tr>
  7.  
  8. </table>
  9.  
  10. </font>
  11.  
  12. <?php
  13.  
  14.  
  15.  
  16. $host = 'localhost';
  17.  
  18. $user = 'user';
  19.  
  20. $password = 'pword';
  21.  
  22.  
  23.  
  24. $txt_db_name = 'db';
  25.  
  26.  
  27.  
  28. $connection = mysql_connect("$host","$user","$password")
  29.  
  30. or die(mysql_error());
  31.  
  32. mysql_select_db("$txt_db_name",$connection)
  33.  
  34. or die(mysql_error());
  35.  
  36.  
  37.  
  38. $updated_query = mysql_query(SELECT * FROM comments1)
  39.  
  40.  
  41.  
  42. $result = mysql_fetch_row($updated_query); echo $result[0];
  43.  
  44. </BODY>
  45.  
  46. </HTML>
  47.  
  48. ?>
  49.  
  50.  



now get


Parse error: syntax error, unexpected T_STRING on line 19
  • Prime
  • Professor
  • Professor
  • User avatar
  • Posts: 935
  • Loc: Liverpool

Post 3+ Months Ago

Try this
Quote:
<!-- Close the table cell & row it is in -->
</td></tr>
</table>
</font>
<?php

$host = 'localhost';
$user = 'user';
$password = 'pword';

$txt_db_name = 'db';

$connection = mysql_connect("$host","$user","$password")
or die(mysql_error());
mysql_select_db("$txt_db_name",$connection)
or die(mysql_error());

$updated_query = mysql_query("SELECT * FROM comments1");

$result = mysql_fetch_row($updated_query); echo "{$result[0]}";
</BODY>
</HTML>
?>


Hope that helps.

Cheers, Prime ...
  • Zackeriney
  • Graduate
  • Graduate
  • Zackeriney
  • Posts: 128

Post 3+ Months Ago

cheers i hav to put the </body> and </html> after the ?> because i had an error, think its working now, cheers
  • Zackeriney
  • Graduate
  • Graduate
  • Zackeriney
  • Posts: 128

Post 3+ Months Ago

Just noticed that it only displays the first and then stops, can i make it display all of them but backwords. eg latest one shows up first, then the next latest etc etc?

cheers
  • Prime
  • Professor
  • Professor
  • User avatar
  • Posts: 935
  • Loc: Liverpool

Post 3+ Months Ago

Quote:
<!-- Close the table cell & row it is in -->

</td></tr>

</table>

</font>

<?php

$host = 'localhost';

$user = 'user';

$password = 'pword';

$txt_db_name = 'db';

$connection = mysql_connect("$host","$user","$password")

or die(mysql_error());

mysql_select_db("$txt_db_name",$connection)

or die(mysql_error());

$updated_query = mysql_query("SELECT * FROM comments1");

$result = mysql_fetch_row($updated_query);

$count = count($result);

for($i=0;$i<$count;$i++)
{
echo "{$result[$i]}";
}
?>

</BODY>

</HTML>


... or something like that.

Post Information

  • Total Posts in this topic: 8 posts
  • Users browsing this forum: No registered users and 89 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.