0

I have this error :Parse error: syntax error, unexpected '$db_field' (T_VARIABLE) in C:\Program Files (x86)\EasyPHP-12.1\www\penet.hi2.ro\cheats.php on line 110

And the code is :

<?PHP
                require ("connect.php");
                //$db_handle = mysql_connect($server, $user_name, $password); =>$connect
                $db_found = mysql_select_db($_mysql_db, $connect);

                if ($db_found) {

                $SQL = "SELECT * FROM cheats";
                $result = mysql_query($SQL);

                while ($db_field = mysql_fetch_assoc($result)) 
                {
                    //print ("<li>");
                    //print ("<a href="$db_field['Image'] . " class="pirobox" title="$db_field['Titlu'] . ">");
                    //print ("<img src="$db_field['Image'] . " alt="" /></a>");
                    //print ("<p>$db_field['Content'] . </p>");
                    //print ("<div class="button"><pre><a href="nextgen.php">Read more</a><a href="$db_field['Download'] . ">Download</a></pre></div>");
                    //print ("</li>");
                    $mesaj="<li><a href="$db_field['Image']" class="pirobox" title="$db_field['Titlu']"><img src="$db_field['Image']"/></a><p>$db_field['Content']</p><div class="button"><pre><a href="index.php">Read More</a><a href="$db_field['Download']">Download</a></pre></div></li>";
                    print ("$mesaj");

                    //print $db_field['Titlu'] . "<BR>";
                    //print $db_field['Content'] . "<BR>";
                    //print $db_field['Image'] . "<BR>";
                    //print $db_field['Download'] . "<BR>";
                }

                mysql_close($connect);

                }
                else {
                print "Database NOT Found ";
                mysql_close($connect);
                }

            ?>

Line 110 is $mesaj="..."

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by broj1
2

Firstly: you are mixing double quotes for PHP strings with double quotes for html attributes. Escape the later.
Secondly: composite variables in a string should be enclosed in curly braces to get parsed correctly.

$mesaj="<li><a href=\"{$db_field['Image']}\" class=\"pirobox\" title=\"{$db_field['Titlu']}\"><img src=\"{$db_field['Image']}\"/></a><p>{$db_field['Content']}</p><div class=\"button\"><pre><a href=\"index.php\">Read More</a><a href=\"{$db_field['Download']}\">Download</a></pre></div></li>";

Edited by broj1

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.