jason360 Posted April 17, 2011 Share Posted April 17, 2011 Could someone please help me with this syntax error? I can't figure out what is wrong...i am a beginner. Screenshot attached. Any help is appreciated. Thanks Here is the code I am having trouble with: <?php include 'config.inc.php'; // initialization $photo_upload_fields = ''; $counter = 1; // If we want more fields, then use, preupload.php?number_of_fields=20 $number_of_fields = (isset($_GET['number_of_fields'])) ? (int)($_GET['number_of_fields']) : 5; // Firstly Lets build the Category List $result = mysql_query('SELECT category_id,category_name FROM gallery_category'); while($row = mysql_fetch_array($result)) { $photo_category_list .= <<<__HTML_END <option value="$row[0]">$row[1]</option>\n __HTML_END; } mysql_free_result( $result ); // Lets build the Image Uploading fields while($counter <= $number_of_fields) { $photo_upload_fields .= <<<__HTML_END <tr><td> Photo {$counter}: <input name="photo_filename[]" type="file" /> </td></tr> <tr><td> Caption: <textarea name="photo_caption[]" cols="30" rows="1"></textarea> </td></tr> __HTML_END; $counter++; } // Final Output echo <<<__HTML_END <html> <head> <title>Lets upload Photos</title> </head> <body> <form enctype="multipart/form-data" action="upload.php" method="post" name="upload_form"> <table width="90%" border="0" align="center" style="width: 90%;"> <tr><td> Select Category <select name="category"> $photo_category_list </select> </td></tr> <! - Insert the image fields here --> $photo_upload_fields <tr><td> <input type="submit" name="submit" value="Add Photos" /> </td></tr> </table> </form> </body> </html> __HTML_END; ?> [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/234000-php-syntax-error-help/ Share on other sites More sharing options...
dcro2 Posted April 17, 2011 Share Posted April 17, 2011 I guess you're familiar with the heredoc syntax? Read this. echo <<<DELIMITER blah blah DELIMITER; In your case, the delimiter is __HTML_END For some reason, you have three spaces at the end of every line, but the starting and end lines of these heredoc statements cannot contain ANY whitespace after the delimiter. They must immediately be followed by a newline character. Remove the spaces at the end of the lines every time you use those delimiters. More specifically, at lines 15, 17, 23, 34, 39, and 66. Quote Link to comment https://forums.phpfreaks.com/topic/234000-php-syntax-error-help/#findComment-1202746 Share on other sites More sharing options...
Skewled Posted April 17, 2011 Share Posted April 17, 2011 Place your code in tags. In the editor for the post you'll see # select your code and click it. Check out: http://us2.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc <?php include 'config.inc.php'; // initialization $photo_upload_fields = ''; $counter = 1; // If we want more fields, then use, preupload.php?number_of_fields=20 $number_of_fields = (isset($_GET['number_of_fields'])) ? (int)($_GET['number_of_fields']) : 5; // Firstly Lets build the Category List $result = mysql_query('SELECT category_id,category_name FROM gallery_category'); while($row = mysql_fetch_array($result)) { $photo_category_list .= <<<__HTML_END <option value="$row[0]">$row[1]</option>\n __HTML_END; } mysql_free_result( $result ); // Lets build the Image Uploading fields while($counter <= $number_of_fields) { $photo_upload_fields .= <<<__HTML_END <tr><td> Photo {$counter}: <input name="photo_filename[]" type="file" /> </td></tr> <tr><td> Caption: <textarea name="photo_caption[]" cols="30" rows="1"></textarea> </td></tr> __HTML_END; $counter++; } // Final Output echo <<<__HTML_END <html> <head> <title>Lets upload Photos</title> </head> <body> <form enctype="multipart/form-data" action="upload.php" method="post" name="upload_form"> <table width="90%" border="0" align="center" style="width: 90%;"> <tr><td> Select Category <select name="category"> $photo_category_list </select> </td></tr> <! - Insert the image fields here --> $photo_upload_fields <tr><td> <input type="submit" name="submit" value="Add Photos" /> </td></tr> </table> </form> </body> </html> __HTML_END; ?> Quote Link to comment https://forums.phpfreaks.com/topic/234000-php-syntax-error-help/#findComment-1202747 Share on other sites More sharing options...
jason360 Posted April 18, 2011 Author Share Posted April 18, 2011 dcro2 Thanks alot!! Worked perfect! A++++ :D :D 8) 8) Quote Link to comment https://forums.phpfreaks.com/topic/234000-php-syntax-error-help/#findComment-1202803 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.