Connecting Tech Pros Worldwide Forums | Help | Site Map

Parse error: syntax error, unexpected T_VARIABLE on line 4

Newbie
 
Join Date: Dec 2007
Posts: 2
#1: Dec 24 '07
I am getting the error Parse error: syntax error, unexpected T_VARIABLE on line 4 but I can't seem to find what is wrong. Could someone please help.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $conn = @mysql_connect("localhost", "root", "password ")
  3.  
  4. $rs1 = @mysql_create_db( $_REQUEST['db'] );
  5.  
  6. $rs2 = @mysql_list_dbs( $conn );
  7. for( $row =0; $row < mysql_num_rows( $rs2 ); $row++ )
  8. { $list .= mysql_tablename( $rs2, $row) ." | "; }
  9. ?>
  10.  
  11. <html>
  12. <head>
  13. <title>Creating databases</title>
  14. </head>
  15. <body>
  16.  
  17. <form action = "<?php echo( $_SERVER['PHP_SELF'] ); ?>"
  18. method="post">Current databases: <?php echo( $list ); ?>
  19. <hr>Name:<input type = "text" name= "db">
  20. <input type = "submit" value = "Create Database">
  21. </form>
  22.  
  23. </body>
  24. </html>

pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#2: Dec 24 '07

re: Parse error: syntax error, unexpected T_VARIABLE on line 4


Heya, NeedHelp. Welcome to TSDN!

You're missing a semicolon on line 2.
Newbie
 
Join Date: Dec 2007
Posts: 2
#3: Dec 24 '07

re: Parse error: syntax error, unexpected T_VARIABLE on line 4


Quote:

Originally Posted by pbmods

Heya, NeedHelp. Welcome to TSDN!

You're missing a semicolon on line 2.

I tried putting that in then the screen just comes up blank. No errors, but nothing else either.
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#4: Dec 24 '07

re: Parse error: syntax error, unexpected T_VARIABLE on line 4


Heya, NeedHelp.

Check out this article to find out what is going on.
Member
 
Join Date: Sep 2006
Posts: 63
#5: Dec 25 '07

re: Parse error: syntax error, unexpected T_VARIABLE on line 4


get rid of the @ in front of mysql commands. That suppresses any error messages you may have from sql. Then rerun the script and see what you get.
In addition to that, you php script should probably execute when you get submit and not on reload.
Reply