Php Error

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

jaybeeb

Thread Starter
Joined
Mar 30, 2008
Messages
51
Having trouble linking a mysql table/database through php, I have all my open, close and config php files setup correctly.

Here is my error:
Parse error: syntax error, unexpected '"' in C:\wamp\www\test1.php on line 20
PHP:
<?php

  include 'config.php';
  include 'opendb.php';

$query="SELECT User_Name,User_ID,Staff_ID,Problem,Problem_ID,User_email,Staff_email, FROM itsupport";
$result=mysql_query($query);
while($row=mysql_fetch_array($result, MYSQL_ASSOC))
	{
                 echo "User_Name :{$row[' User_Name ']} <br>" .     <!--LINE 20--> 
		            "User_ID : {$row[' User_ID ']} <br>" . 
			       "Staff_ID :{$row[' Staff_ID ']} <br>".
			           "Problem : {$row[' Problem ']} <br><br>".
				      "Problem_ID :{$row[' Problem_ID ']} <br>".
					"User_email :{$row[' User_email ']} <br>".
					  "Staff_email :{$row[' Staff_email ']} <br>";
					  
										
		} 
		
		include 'closedb.php';
Any ideas? I am a novice when it comes to PHP so it coulde be something simple.
 

MMJ

Guest
Joined
Oct 15, 2006
Messages
3,625
The error is probably because of the white-space in the array keys.

PHP:
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
	echo "User_Name :{$row['User_Name']} <br>" .
	"User_ID : {$row['User_ID']} <br>" . 
	"Staff_ID :{$row['Staff_ID']} <br>".
	"Problem : {$row['Problem']} <br><br>".
	"Problem_ID :{$row['Problem_ID']} <br>".
	"User_email :{$row['User_email']} <br>".
	"Staff_email :{$row['Staff_email']} <br>";						
}
 

jaybeeb

Thread Starter
Joined
Mar 30, 2008
Messages
51
Please post the code you are using.
It is basically the same as the first time I posted just without the spaces that you said to get rid of.
Thanks for taking the time to look at it

PHP:
   <?php

  include 'config.php';
  include 'opendb.php';

$query="SELECT User_Name,User_ID,Staff_ID,Problem,Problem_ID,User_email,Staff_email, FROM itsupport";
$result=mysql_query($query);
while($row=mysql_fetch_array($result, MYSQL_ASSOC))
    {
                 echo "User_Name :{$row['User_Name']} <br>" .     <!--LINE 20--> 
                    "User_ID : {$row['User_ID']} <br>" . 
                   "Staff_ID :{$row['Staff_ID']} <br>".
                       "Problem : {$row['Problem']} <br><br>".
                      "Problem_ID :{$row['Problem_ID']} <br>".
                    "User_email :{$row['User_email']} <br>".
                      "Staff_email :{$row['Staff_email']} <br>";
                      
                                        
        } 
        
        include 'closedb.php';
 

MMJ

Guest
Joined
Oct 15, 2006
Messages
3,625
Hmm... I tried the code and it worked fine. Make sure you remove <!--LINE 20--> before running the code.
 

jaybeeb

Thread Starter
Joined
Mar 30, 2008
Messages
51
Hmm... I tried the code and it worked fine. Make sure you remove <!--LINE 20--> before running the code.
lol, I only put in "Line 20" in my post to let you know where it is. I have tried the exact code on 3 different machines and keep getting the same error :mad:
 

MMJ

Guest
Joined
Oct 15, 2006
Messages
3,625
1. Make sure the page is not cached (hit CTRL + F5).

2. If that doesn't work than use this code:

PHP:
    echo 'User_Name : '.$row['User_Name'] .'<br>' .
    'User_ID : '.$row['User_ID'] .'<br>' .
    'Staff_ID : '.$row['Staff_ID'] .'<br>'.
    'Problem : '.$row['Problem'] .'<br><br>'.
    'Problem_ID : '.$row['Problem_ID'] .'<br>'.
    'User_email : '.$row['User_email'] .'<br>'.
    'Staff_email : '.$row['Staff_email'] .'<br>';
 
Joined
Oct 25, 2007
Messages
551
I only put in "Line 20" in my post to let you know where it is.
<!-- --> is the HTML comment tag - PHP uses // for single line comments or /* comment goes here*/ for multiline comments. It's best to use these when posting extra information in your code so everyone knows it's not that causing the error :)
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top