lpxxfaintxx Posted March 21, 2006 Share Posted March 21, 2006 [code] <html> <p>Category: <label> <select name="Category" id="Category"><option value="NULL">Choose A Category:</option> <?php $query = 'SELECT * FROM registered_cat ORDER BY cat_name ASC'; $result = mysql_query ($query); while ($row = mysql_fetch_array ($result, MYSQL_NUM)) { echo "<option value='$row[0]'>$row[1]</option>"; ?> </select></html>[/code]I don't know where it went wrong, but its not working no matter what I tried. Can anyone spot the error? Quote Link to comment https://forums.phpfreaks.com/topic/5409-parse-error-parse-error-unexpected/ Share on other sites More sharing options...
kenrbnsn Posted March 21, 2006 Share Posted March 21, 2006 You forgot the closing curly brace on the "while" statement.Ken Quote Link to comment https://forums.phpfreaks.com/topic/5409-parse-error-parse-error-unexpected/#findComment-19307 Share on other sites More sharing options...
redbullmarky Posted March 21, 2006 Share Posted March 21, 2006 you have two problems, both in the same block. you need to treat array values differently to normal variables when putting them in double quotes (use curly braces {}), and you also need a closing bracket for your while loop. so:[code]while ($row = mysql_fetch_array($result, MYSQL_NUM)) { echo "<option value='{$row[0]}'>{$row[1]}</option>"; <-- curly braces} <--- you forgot this?>[/code]that should do youCheers Quote Link to comment https://forums.phpfreaks.com/topic/5409-parse-error-parse-error-unexpected/#findComment-19308 Share on other sites More sharing options...
kenrbnsn Posted March 21, 2006 Share Posted March 21, 2006 No, actually they way the OP has that statement does work. Try it with the following example code:[code]<?php$row = array('xyz','123');echo "<option value='$row[0]'>$row[1]</option>"; ?>?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/5409-parse-error-parse-error-unexpected/#findComment-19311 Share on other sites More sharing options...
lpxxfaintxx Posted March 21, 2006 Author Share Posted March 21, 2006 Thanks, I'll check it out now.edit: Ok, I have this now: [code]<?php$username = $userdata['user_name'];?><center><form enctype='multipart/form-data' action='upload.php' method='post'> <p>Image Name: <label> <input type="text" name="textfield" /> </label> </p> <p>Image Description: <br /> <label> <textarea name="description" cols="50" rows="2"></textarea> </label> </p> <p>Category: <label> <select name="Category" id="Category"><option value="NULL">Choose A Category:</option> <?php $query = 'SELECT * FROM registered_cat ORDER BY cat_name ASC'; $result = mysql_query ($query); while ($row = mysql_fetch_array ($result, MYSQL_NUM)) {echo "<option value='$row[0]'>{$row[1]}</option>";} ?> </select> </label> <br /> <input type='hidden' name='MAX_FILE_SIZE' value='1048576'> <input name='userfile' type='file'> <input type='submit' value='Upload'> </p> <p> </p></form>[/code]but the options "Category" doesn't grab the information from the database. It just comes out blank, the MySQL database exists and has values in it, so it must be the PHP. Quote Link to comment https://forums.phpfreaks.com/topic/5409-parse-error-parse-error-unexpected/#findComment-19458 Share on other sites More sharing options...
kenrbnsn Posted March 21, 2006 Share Posted March 21, 2006 The "<" in this line[code]<?php echo "<option value='$row[0]'>{$row[1]}</option>";} ?>[/code]was just to show one of the other people that your original code on this line was fine (It prevents the browser from interpreting the line). I didn't mean for you to change your line, put back the "<" character there.Ken Quote Link to comment https://forums.phpfreaks.com/topic/5409-parse-error-parse-error-unexpected/#findComment-19462 Share on other sites More sharing options...
lpxxfaintxx Posted March 21, 2006 Author Share Posted March 21, 2006 Haha, I knew that :P(Sarcasm) The only thing I hate about PHP is the syntax. One little syntax error, and the whole script doesnt work. Hehe, other than that, I'm in love. Quote Link to comment https://forums.phpfreaks.com/topic/5409-parse-error-parse-error-unexpected/#findComment-19465 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.