-1

I'm trying to populate an HTML table with MySQL data, but I'm getting an error at line 128 (i.e. just after the line with $row['location']) that says: T_CONSTANT_ENCAPSED_STRING. I've Googled around, but I can't really get a handle on what that means or where I might be going wrong. Any help would be greatly appreciated. Thanks :)

echo "<table id='row1_border'>";
                    while($row = mysql_fetch_array($result)) ;
                    {
                    echo "<tbody>";
                        echo "<tr class='job_listing'>";
                            echo "<td class='job'>";
                                echo "<div class='company_image'></div>";

                                echo "<div class='job_title'>";
                                    echo "<span class='job_title_style'></span>";
                                echo "</div>";
                                echo "<div class='company_name'>";
                                    echo "<span class='company_name_style'>Akin, Gump, and Smith</span>";
                                echo "</div>";
                                echo "<div class='company_tagline'>";
                                    echo "<span class='company_tagline_style'>This is just a test.</span>";
                                echo "</div>";
                            echo "</td>";
                            echo "<td class='location'>";
                                echo "<div class='location_div'>";
                                    echo "<span class='location_style'>";
                                        $row['location']

                                "</span>";
                                echo "</div>";
                            echo "</td>";
                            echo "<td class='job_type'>";
                                echo "<div class='job_type_div'>";
                                    echo "<span class='job_type_style'>";

                                        echo .$row['job_type'].
                                    "</span>";
                                echo "</div>";
                            echo "</td>";
                        echo "</tr>";
                    echo "</tbody>";
                    }
                echo "</table>"

                ?>
1
  • Please stop writing new code with the ancient mysql_* functions. They are no longer maintained and community has begun the deprecation process . Instead you should learn about prepared statements and use either PDO or MySQLi. If you care to learn, here is a quite good PDO-related tutorial. Commented Apr 22, 2012 at 23:39

4 Answers 4

1

You don't have echo before the line in question, try:

echo $row['location'];

The line after this one isn't echoed properly as well.

Make sure you are echoing each line.

Sign up to request clarification or add additional context in comments.

1 Comment

Hi there, thanks so much for getting back to me. I just added the echoes and reloaded. Now I get a new error: Parse error: syntax error, unexpected T_ECHO, expecting ',' or ';' Any idea why? Thanks again!
0

Good luck

<table><tbody>
<?php while($row = mysql_fetch_array($result)) { ?>
                    <tr class='job_listing'>
                        <td class='job'>
                            <div class='company_image'></div>

                            <div class='job_title'>
                                <span class='job_title_style'></span>
                            </div>
                            <div class='company_name'>
                                <span class='company_name_style'>Akin, Gump, and Smith</span>
                            </div>
                            <div class='company_tagline'>
                                <span class='company_tagline_style'>This is just a test.</span>
                            </div>
                        </td>
                        <td class='location'>
                            <div class='location_div'>
                                <span class='location_style'>
                                   <?php  echo $row['location']; ?>

                            </span>
                            </div>
                        </td>
                        <td class='job_type'>
                            <div class='job_type_div'>
                                <span class='job_type_style'>

                                    <?php  $row['job_type']; ?>
                                </span>
                            </div>
                        </td>
                    </tr>
                    <?php } ?>
                </tbody>
            </table>

Comments

0

try this

echo "<td class='location'>";
     echo "<div class='location_div'>";
         echo "<span class='location_style'>".$row['location']."</span>";                   
     echo "</div>";
 echo "</td>";
 echo "<td class='job_type'>";
     echo "<div class='job_type_div'>";
         echo "<span class='job_type_style'>".$row['job_type']."</span>";
     echo "</div>";
 echo "</td>";

5 Comments

if that doesn' work try $row = mysql_fetch_array($result); print_r($row); without all the table html
So good news and bad news. The good news is that the page loaded without any parse errors. The bad news is that the data didn't get pulled into the table. @AL90 I think I know what you mean, but can you flesh it out a little more? Thanks :)
try replacing $row['location'] with $row[0] and $row['job_type'] with $row[1]. most of the time mysql will set it's array values as number values instead of the actual column names
Okay, just tried that and no luck :( If it were a problem with mysql, then I would have expected it to display something...maybe a problem with syntax then?
are you able to see the html table borders? If you are, then that means that your html code is correct and your mysql code is echoed incorrectly. If it is the mysql code then comment out all your table html and post this in your page <?$row = mysql_fetch_array($result); print_r($row);?>. If that works then it should spill out all of your mysql query, if that doesn't do it then you are not querying your data correctly
0

It's because you need the semicolon.

I would advise you to read the error in the future.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.