please help me to find the problem w/ my code. i'm nearly finished w/ this page, but i can't get past this error. i'm sure i've got quite the blunder here!
Note: i was using $special_day in the php varilable's html below as in
<p>add ".$special_day."s drink specials</p>";
but i think it was the cause of an error. hard for me to tell at this point in my php career!
<?php
$conn_day_check = mysql_connect("localhost", "myuser", "mypass") or die(mysql_error());
mysql_select_db("cb_shows1", $conn_day_check) or die(mysql_error());
$check_day_id = "select day_id from days_table";
$check_day_id_res = mysql_query($check_day_id) or die(mysql_error());
// LOGIC= IF RESULTS <= 0 THEN DAY IS MONDAY ETC
if ($check_day_id_res == 0) {
$day_of_week = "Monday";
} else if ($check_day_id_res == 1) {
$day_of_week = "Tuesday";
} else if ($check_day_id_res == 2) {
$day_of_week = "Wednesday";
} else if ($check_day_id_res == 3) {
$day_of_week = "Thursday";
} else if ($check_day_id_res == 4) {
$day_of_week = "Friday";
} else if ($check_day_id_res == 5) {
$day_of_week = "Saturday";
} else if ($check_day_is_res == 6) {
$day_of_week = "Sunday";
if ($_POST['op'] != "add") {
// TESTING MATCH FOR HIDDEN FOR FIELD ABOVE. IT WILL ALWAYS FAIL FIRST TIME SO THE FORM IS IN FACT DISPLAYED
$special_day = $day_of_week;
$display_block = "<h1>Add a Day's Specials:</h1>
<form method="post" action="$_SERVER[PHP_SELF]" >
<p>NOTE: You must add every day's specials before adding concert dates!</p>
<p><strong>:</strong></p>
<p>Add 's Drink Specials here:</p>
<input type="text" name="drink" size="40" maxlength="45" />
<input type="text" name="drink_price" size="40" maxlength="45" />
<input type="text" name="beer" size="40" maxlength="45" />
<input type="text" name="beer_price" size="40" maxlength="45" />
<input type="text" name="pitcher" size="40" maxlength="45" />
<input type="text" name="pitcher_price" size="40" maxlength="45" />
<p><strong>Comments (optional):</strong>
<br />
<textarea name="misc" cols="35" rows="5" wrap="virtual">
</textarea>
</p>
<input type="hidden" name="op" value="add" />
<p><input type="submit" name="submit" value="Add 's Drink Specials" />
</p>
</form>";
} else if ($_POST['op'] == "add") {
//CHECKS FOR FIELDS REQUIRED TO SUBMIT THE FORM. IF MISSING DATA, FORM WILL RELOAD
if (($_POST['drink'] == "") || ($_POST['beer'] == "") || ($_POST['pitcher'] == "")) {
header("Location: add_a_day.php");
exit;
}
// CONNECT TO DATABASE
$conn = mysql_connect("localhost", "myuser", "mypass")
or die(mysql_error());
mysql_select_db("cb_shows1", $conn) or die(mysql_error());
// ADD TO DAYS_OF_WEEK TABLE
$add_specials = "insert into days_table values ('', '$special_day', '', '$_POST[drink]', '$_POST[drink_price]', '', '$_POST[beer]', '$_POST[beer_price]', '', '$_POST[pitcher]', '$_POST[pitcher_price]', '$_POST[misc]')";
$drink = $_POST['drink'];
$drink_price = $_POST['drink_price'];
$beer = $_POST['beer'];
$beer_price = $_POST['beer_price'];
$pitcher = $_POST['pitcher'];
$pitcher_price = $_POST['pitcher_price'];
$specials_notes = $_POST['misc'];
mysql_query($add_specials) or die(mysql_error());
$display_block = "<h1>Artist Entry Added</h1>
<p>The following info was inserted into the Crowbar Concert Database - Artist Table:</p>
<h3 class="stickout">Drink Special & Price:</h3>
<p>$drink - $drink_price</p>
<h3 class="stickout">Beer Special & Price:</h3>
<p>$beer - $beer_price</p>
<h3 class="stickout">Pitcher & Price:</h3>
<p>$pitcher - $pitcher_price</p>
<h3 class="stickout">Misc Notes:</h3>
<p>$specials_notes</p>
<p class="stickout">Would you like to <a href="add_a_day.php">add another</a> entry?</p>
<p>View existing <a href="selentry.php">Table Data.</a></p>
<p>View Specific Concert Date</p>
<p>View All Options</p>";
?>
<html>
<head>
<title>Add an Entry</title>
<link rel="stylesheet" type="text/css" href="css/php.css" />
</head>
<body>
<?php
echo $display_block; ?>
</body>
</html>
although i definitely need to know why i'm getting this error-- maybe you could help me also w/ a better way to populate the table altogther?
geesh! i can't wait to show you the app... i wonder if i'll ever get 'er working!
:eek: