Xtremer360 Posted October 6, 2008 Share Posted October 6, 2008 Can someone tell me why I keep getting a error like this for my select drop down: Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/content/y/a/n/yankeefaninkc/html/backstage/setupshow.php on line 15 <?php /* setupshow.php */ /* This form after submission takes the results of the form and makes a new show ready for adding matches. */ require ('database.php'); echo '<form action="setupshow.php" method="post">'; echo '<fieldset>'; echo '<legend>Enter the following information to setup a show:</legend>'; echo '<p>Weekly Show or Pay-Per View:<select name="type" onChange="showShows(this.value)"><option value="">Select a Show Type</option> <?php $query = 'SELECT type FROM shows'; while ($row = mysql_fetch_array($result, MYSQL_NUM)){ echo "<option value=\"$row['type']\">$row['type']</option>\r"; } ?></select></p>'; echo '<p>Show Name:<select name="type"><option></option></select></p>'; echo '<p>Show Label:<input name="showlabel" type="text" readonly="true" size="5"></p>'; echo '<p>Location:<input name="location" type="text"></p>'; echo '<p>Arena:<input name="arena" type="text"></p>'; echo '<div align="center"><input name="submit" type="submit"><input name="sumbitted" type="hidden" value="TRUE"></div>'; echo '</fieldset>'; echo '</form>'; ?> Quote Link to comment Share on other sites More sharing options...
F1Fan Posted October 6, 2008 Share Posted October 6, 2008 echo '<p>Weekly Show or Pay-Per View:<select name="type" onChange="showShows(this.value)"><option value="">Select a Show Type</option> <?php See the problem, or problems? I believe there are several others. You're escaping your PHP, but then continuing to enter PHP code, and you're missing semicolons. Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted October 6, 2008 Author Share Posted October 6, 2008 Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/content/y/a/n/yankeefaninkc/html/backstage/setupshow.php on line 15 <?php /* setupshow.php */ /* This form after submission takes the results of the form and makes a new show ready for adding matches. */ require ('database.php'); echo '<form action="setupshow.php" method="post">'; echo '<fieldset>'; echo '<legend>Enter the following information to setup a show:</legend>'; echo '<p>Weekly Show or Pay-Per View:<select name="type" onChange="showShows(this.value)"><option value="">Select a Show Type</option> $query = 'SELECT type FROM shows'; while ($row = mysql_fetch_array($result, MYSQL_NUM)){ echo "<option value=\"$row['type']\">$row['type']</option>\r"; } </select></p>'; echo '<p>Show Name:<select name="type"><option></option></select></p>'; echo '<p>Show Label:<input name="showlabel" type="text" readonly="true" size="5"></p>'; echo '<p>Location:<input name="location" type="text"></p>'; echo '<p>Arena:<input name="arena" type="text"></p>'; echo '<div align="center"><input name="submit" type="submit"><input name="sumbitted" type="hidden" value="TRUE"></div>'; echo '</fieldset>'; echo '</form>'; ?> Quote Link to comment Share on other sites More sharing options...
F1Fan Posted October 6, 2008 Share Posted October 6, 2008 Read your error! ...expecting ',' or ';'...on line 15 Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted October 6, 2008 Author Share Posted October 6, 2008 $query = 'SELECT type FROM shows'; That's line 15 and looking at is show a semicolon. Quote Link to comment Share on other sites More sharing options...
F1Fan Posted October 6, 2008 Share Posted October 6, 2008 Yes, there is a semicolon at the END of that line, BUT you're missing one before it (it should go at the end of your line 13, but PHP is trying to tell you that you're missing one before the "$..." on line 15. echo '<p>Weekly Show or Pay-Per View:<select name="type" onChange="showShows(this.value)"><option value="">Select a Show Type</option> needs to be echo '<p>Weekly Show or Pay-Per View:<select name="type" onChange="showShows(this.value)"><option value="">Select a Show Type</option>; Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted October 6, 2008 Author Share Posted October 6, 2008 Why so many errrors? Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/content/y/a/n/yankeefaninkc/html/backstage/setupshow.php on line 14 <?php /* setupshow.php */ /* This form after submission takes the results of the form and makes a new show ready for adding matches. */ require ('database.php'); echo '<form action="setupshow.php" method="post">'; echo '<fieldset>'; echo '<legend>Enter the following information to setup a show:</legend>'; echo '<p>Weekly Show or Pay-Per View:<select name="type" onChange="showShows(this.value)"><option value="">Select a Show Type</option>; $query = 'SELECT type FROM shows'; while ($row = mysql_fetch_array($result, MYSQL_NUM)){ echo "<option value=\"$row['type']\">$row['type']</option>\r"; } </select></p>'; echo '<p>Show Name:<select name="type"><option></option></select></p>'; echo '<p>Show Label:<input name="showlabel" type="text" readonly="true" size="5"></p>'; echo '<p>Location:<input name="location" type="text"></p>'; echo '<p>Arena:<input name="arena" type="text"></p>'; echo '<div align="center"><input name="submit" type="submit"><input name="sumbitted" type="hidden" value="TRUE"></div>'; echo '</fieldset>'; echo '</form>'; ?> Quote Link to comment Share on other sites More sharing options...
F1Fan Posted October 6, 2008 Share Posted October 6, 2008 Sorry I missed (and so did you) a single quote just before that semicolon. Please check all of your single quotes, double quotes, and semicolons thoroughly before assuming there's something bigger wrong. Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted October 6, 2008 Author Share Posted October 6, 2008 Fixed hower what does this mean: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/y/a/n/yankeefaninkc/html/backstage/setupshow.php on line 16 Quote Link to comment Share on other sites More sharing options...
F1Fan Posted October 6, 2008 Share Posted October 6, 2008 That means that you're putting some variables and other things inside of a string improperly. For instance, in this code: echo "<option value=\"$row['type']\">$row['type']</option>\r"; You can't use arrays in a double quoted string without {} brackets around them. So use: echo "<option value=\"{$row['type']}\">{$row['type']}</option>\r"; Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted October 6, 2008 Author Share Posted October 6, 2008 Now I can see the entire form. However the first select field will not show the different types of shows. Why coudl that be? <?php /* setupshow.php */ /* This form after submission takes the results of the form and makes a new show ready for adding matches. */ require ('database.php'); echo '<form action="setupshow.php" method="post">'; echo '<fieldset>'; echo '<legend>Enter the following information to setup a show:</legend>'; echo '<p>Weekly Show or Pay-Per View:<select name="type" onChange="showShows(this.value)"><option value="">Select a Show Type</option>'; $query = 'SELECT type FROM shows'; while ($row = mysql_fetch_array($result, MYSQL_NUM)){ echo "<option value=\"{$row['type']}\">{$row['type']}</option>\r"; } '</select></p>'; echo '<p>Show Name:<select name="type"><option></option></select></p>'; echo '<p>Show Label:<input name="showlabel" type="text" readonly="true" size="5"></p>'; echo '<p>Location:<input name="location" type="text"></p>'; echo '<p>Arena:<input name="arena" type="text"></p>'; echo '<div align="center"><input name="submit" type="submit"><input name="sumbitted" type="hidden" value="TRUE"></div>'; echo '</fieldset>'; echo '</form>'; ?> Quote Link to comment Share on other sites More sharing options...
F1Fan Posted October 6, 2008 Share Posted October 6, 2008 Well, your code calls the JavaScript showShows function, and that isn't listed here, so I have no idea what it is supposed to do. Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted October 6, 2008 Author Share Posted October 6, 2008 Well I even took it out to see if it'd show all the different types of shows and still doesn't show anything. Quote Link to comment Share on other sites More sharing options...
F1Fan Posted October 6, 2008 Share Posted October 6, 2008 I would guess that there are no rows in your DB table. Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted October 6, 2008 Author Share Posted October 6, 2008 I have two test rows to see if the script will work Quote Link to comment Share on other sites More sharing options...
F1Fan Posted October 6, 2008 Share Posted October 6, 2008 Replace this: while ($row = mysql_fetch_array($result, MYSQL_NUM)){ with this: while ($row = mysql_fetch_assoc($result)){ Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted October 6, 2008 Author Share Posted October 6, 2008 Didn't do anything? ANd that's odd because when I go into mysqladmin and put in SELECT type FROM shows into the SQL it shows up with the two different types so something has to be wrong with the call. Quote Link to comment Share on other sites More sharing options...
F1Fan Posted October 6, 2008 Share Posted October 6, 2008 Sounds like the connect code isn't working. Re-post all of your code, including your database.php code. Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted October 6, 2008 Author Share Posted October 6, 2008 This is my database.php file. <?php // This script retrieves headline entries from the database. // Address error handing. ini_set ('display_errors', 1); error_reporting (E_ALL & ~E_NOTICE); // Connect and select. if ($dbc = @mysql_connect ('___', '___', '___')) { if (!@mysql_select_db ('___')) { die ('<p>Could select the database because: <b>' . mysql_error() . '</b></p>'); } } else { die ('<p>Could not connect to MySQL because: <b>' . mysql_error() . '</b></p>'); } if (get_magic_quotes_gpc()) { function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); return $value; } $_POST = array_map('stripslashes_deep', $_POST); $_GET = array_map('stripslashes_deep', $_GET); $_COOKIE = array_map('stripslashes_deep', $_COOKIE); $_REQUEST = array_map('stripslashes_deep', $_REQUEST); } ?> <?php /* setupshow.php */ /* This form after submission takes the results of the form and makes a new show ready for adding matches. */ require ('database.php'); echo '<form action="setupshow.php" method="post">'; echo '<fieldset>'; echo '<legend>Enter the following information to setup a show:</legend>'; echo '<p>Weekly Show or Pay-Per View:<select name="type"><option value="">Select a Show Type</option>'; $query = 'SELECT type FROM shows'; while ($row = mysql_fetch_assoc($result)){ echo "<option value=\"{$row['type']}\">{$row['type']}</option>\r"; } '</select></p>'; echo '<p>Show Name:<select name="type"><option></option></select></p>'; echo '<p>Show Label:<input name="showlabel" type="text" readonly="true" size="5"></p>'; echo '<p>Location:<input name="location" type="text"></p>'; echo '<p>Arena:<input name="arena" type="text"></p>'; echo '<div align="center"><input name="submit" type="submit"><input name="sumbitted" type="hidden" value="TRUE"></div>'; echo '</fieldset>'; echo '</form>'; ?> Quote Link to comment Share on other sites More sharing options...
F1Fan Posted October 6, 2008 Share Posted October 6, 2008 Remove the @ symbol in front of your connect and select_db mysql functions. Those mask errors, and those errors pay tell you your problems. Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted October 6, 2008 Author Share Posted October 6, 2008 Damn still nothing. Quote Link to comment Share on other sites More sharing options...
F1Fan Posted October 6, 2008 Share Posted October 6, 2008 OMG! I can't believe I didn't see this. You're never running the query: <?php $query = 'SELECT type FROM shows'; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)){ ?> Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted October 6, 2008 Author Share Posted October 6, 2008 Damn I didn't even notice that but thank you. Now I just have to figure out how to that select box to whatever the user selects it goes back to the database and selects all the show names with that type and then the show names in that second select box. I modified the code just a tad and don't know why it didn't drop the select box below like it should be. http://kansasoutlawwrestling.com/backstage/setupshow.php <?php /* setupshow.php */ /* This form after submission takes the results of the form and makes a new show ready for adding matches. */ require ('database.php'); echo '<form action="setupshow.php" method="post">'; echo '<fieldset>'; echo '<legend>Enter the following information to setup a show:</legend>'; echo '<p>Weekly Show or Pay-Per View:<select name="type"><option value="">Select a Show Type</option>'; $query = 'SELECT type FROM shows'; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)){ echo "<option value=\"{$row['type']}\">{$row['type']}</option>\r"; } '</select></p>'; echo '<p>Show Name:<select name="showname"><option>Select a Show Name</option></select></p>'; echo '<p>Show Label:<input name="showlabel" type="text" readonly="true" size="5"></p>'; echo '<p>Location:<input name="location" type="text"></p>'; echo '<p>Arena:<input name="arena" type="text"></p>'; echo '<div align="center"><input name="submit" type="submit"><input name="sumbitted" type="hidden" value="TRUE"></div>'; echo '</fieldset>'; echo '</form>'; ?> Quote Link to comment Share on other sites More sharing options...
F1Fan Posted October 6, 2008 Share Posted October 6, 2008 Well, since you're posting in the AJAX board, I'm sure you want to use AJAX to do this. It can be done, but do you have any experience with AJAX? What about JavaScript? Looking at your page, you do not have any JS code. I suggest either going through a tutorial on this page, or go to http://w3schools.com and click on JavaScript and/or AJAX and learn how to use them. Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted October 6, 2008 Author Share Posted October 6, 2008 Which of the two do you suggest using for my page? Quote Link to comment 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.