1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Php Error

Discussion in 'Web Design & Development' started by jaybeeb, Apr 5, 2008.

Thread Status:
Not open for further replies.
Advertisement
  1. jaybeeb

    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:
    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($resultMYSQL_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.
     
  2. MMJ

    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($resultMYSQL_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>";                        
    }
     
  3. jaybeeb

    jaybeeb Thread Starter

    Joined:
    Mar 30, 2008
    Messages:
    51
    Hi, Thanks for the suggestion, but the error still exists???
     
  4. MMJ

    MMJ Guest

    Joined:
    Oct 15, 2006
    Messages:
    3,625
    Please post the code you are using.
     
  5. jaybeeb

    jaybeeb Thread Starter

    Joined:
    Mar 30, 2008
    Messages:
    51
    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($resultMYSQL_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'
     
  6. MMJ

    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.
     
  7. jaybeeb

    jaybeeb Thread Starter

    Joined:
    Mar 30, 2008
    Messages:
    51
    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:
     
  8. MMJ

    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>';
     
  9. Mudley

    Mudley

    Joined:
    Apr 6, 2008
    Messages:
    101
    you can also get rid of the comma after Staff_email in your select statement
     
  10. TheRobatron

    TheRobatron

    Joined:
    Oct 25, 2007
    Messages:
    551
    <!-- --> 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 :)
     
  11. Sponsor

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 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/700646

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice