Jump to content

Izzy-B

Members
  • Posts

    20
  • Joined

  • Last visited

Profile Information

  • Gender
    Female

Izzy-B's Achievements

Newbie

Newbie (1/5)

1

Reputation

1

Community Answers

  1. We can close this (I'll try determine how to mark it resolved). I can clearly see, through exhaustive testing, that the fault must lie with the server, regardless. Thanks, anyway.
  2. @ mac_gyver, thank you so much for replying. This is a third-party form and I apologize that I do not know coding. Would you please instruct where, in the form, I should place - error_get_last() in order to get the information? @ Jacques1, I showed the form to my server techs (Codero) but they didn't see anything that was a flag to them. However, I think coding is outside their normal scope of support. Can you explain what you mean when you suggest using a library? I at a disadvantage; I'm just a girl trying to get her web site going. I apologize for not knowing what this means.
  3. (Please, if one more person on an Internet forum cyber-yells at me or calls me an idiot today, I'm going to really start crying, so just know that, before we start. In fact, it's already too late; I'm already crying. Support forums make me nervous.) I have a simple contact form: <form action="send_form_email.php" method="post"> <div class="clear"> </div> <label>First Name:</label> <INPUT class="textbox left " type="text" name="first_name" value=""> <div class="clear"> </div> <label>Last Name:</label> <INPUT class="textbox left " type="text" name="last_name" value=""> <div class="clear"> </div> <label >E-Mail:</label> <INPUT class="textbox left" type="text" name="email" value=""> <div class="clear"> </div> <label >Phone Number:</label> <INPUT class="textbox left" type="text" name="telephone" value=""> <div class="clear"> </div> <label >Message:</label> <TEXTAREA class="textbox left" name="comments" ROWS="5" COLS="25"></TEXTAREA> <div class="clear"> </div> <INPUT class="pin" type="submit" name="submit" value="submit"> </form> This is my PHP form (send_form_email.php): <?php function isValidEmail($address) { if (filter_var($address, FILTER_VALIDATE_EMAIL) == FALSE) return false; /* explode out local and domain */ list($local, $domain) = explode('@', $address); $localLength = strlen($local); $domainLength = strlen($domain); return ( /* check for proper lengths */ ($localLength > 0 && $localLength < 65) && ($domainLength > 3 && $domainLength < 256) && (checkdnsrr($domain, 'MX') || checkdnsrr($domain, 'A'))); } if (isset($_POST['email'])) { // E-Mail To: $email_to = "me@myexample.com"; $email_subject = "Site Form Feedback"; function died($error) { // your error code can go here echo "There were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error . "<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if (!isset($_POST['first_name']) || !isset($_POST['last_name']) || !isset($_POST['email']) || !isset($_POST['telephone']) || !isset($_POST['comments'])) { died('There appears to be a problem with the form you submitted.'); } $error_message = ""; if (!isValidEmail($_POST['email'])) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[a-z.'-]+$/i"; if (!preg_match($string_exp, $_POST['first_name'])) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if (!preg_match($string_exp, $_POST['last_name'])) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; } if (strlen($_POST['comments']) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if (strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array( "content-type", "bcc:", "to:", "cc:", "href" ); return str_replace($bad, "", $string); } $email_message .= "First Name: " . clean_string($_POST['first_name']) . "\n"; $email_message .= "Last Name: " . clean_string($_POST['last_name']) . "\n"; $email_message .= "Email: " . clean_string($_POST['email']) . "\n"; $email_message .= "Telephone: " . clean_string($_POST['telephone']) . "\n"; $email_message .= "Comments: " . clean_string($_POST['comments']) . "\n"; // create email headers $headers = 'From: me@myexample.com' . "\r\n"; 'Reply-To: ' . $_POST['email'] . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> Thank you for contacting me. I will be in touch with you very soon. <?php } ?> I receive the success message "Thank you for contacting me, etc." upon clicking the submit button. The mail does not arrive in the inbox. It is not in the spam folder or in a queue. I talked to my server and they see no reason that mail is not arriving, barring some coding issue. Mail arrives in the inbox when sending directly from another email account; it only fails when being sent through the contact form. I would so appreciate any help; you just have no idea how much.
  4. I wanted to stop back by today and share something that finally dawned on me around 2:00 this morning, when I was still mulling why the calendar didn't look quite right. In my fervor to have the calendar function, I thoughtlessly omitted including an echo to close the last row, the table and 2 div tags. I corrected this in the code below and also added a bit to get the empty table rows (falling after the last day of the month) to continue to flesh out the table row so that the overall appearance is a bit neater. So you'd compare this page to this page to see what I mean. Edited to include my omissions: <?php $conn = ($GLOBALS["___mysqli_ston"] = mysqli_connect("localhost", "user", "password", "database_")) or die('Cannot connect to the database because: ' . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false))); ?> <!DOCTYPE html> <html lang="en"> <head> <title>Calendar</title> <meta charset="utf-8"> <link rel="stylesheet" type="text/css" media="screen" href="css/master.css"> </head> <body> <?php // calender entries. Use the date as the key (in YYYY/MM/DD format) $entries = array( '2014/8/16' => array( 'EVENT', ) , ); $currMonth = isset($_GET['month']) ? $_GET['month'] : date('n'); $currYear = isset($_GET['year']) ? $_GET['year'] : date('Y'); $today = (($currYear == date('Y')) && ($currMonth == date('n'))) ? date('j') : 0; $currMonth = sprintf('%02d', $currMonth); // pad currMonth with zero's // when using user input, always use prepared statements otherwise could lead to SQL injection attacks $stmt = $conn->prepare('SELECT startdt, description FROM events WHERE YEAR(startdt) = ? AND MONTH(startdt) = ?'); $stmt->bind_param('ii', $currYear, $currMonth); $stmt->execute(); $stmt->bind_result($date, $description); $entries = array(); while ($stmt->fetch()) { $entries[$date][] = $description; } $prevMonth = $currMonth == 1 ? 12 : $currMonth - 1; $nextMonth = $currMonth == 12 ? 1 : $currMonth + 1; $prevYear = $currMonth == 1 ? $currYear - 1 : $currYear; $nextYear = $currMonth == 12 ? $currYear + 1 : $currYear; $day1 = mktime(0, 0, 0, $currMonth, 1, $currYear); $dim = date('t', $day1); $dayN = mktime(0, 0, 0, $currMonth, $dim, $currYear); $dow1 = (date('w', $day1) + 0) % 7; $dowN = (date('w', $dayN) + 0) % 7; $calHead = date('F Y', $day1); echo <<<EOT <div class="calwrapper"> <div class="container"> <div class="fnl first"></div> <div class="adjust"></div> <div class="fnl last"></div> </div> <div class="caldisplay"> <table cellspacing="0"> <tr> <td class="hd"><a class="cal_button" href="$_SERVER[PHP_SELF]?year=$prevYear&month=$prevMonth"> Prev </a></td> <td colspan="5" class="adjust">$calHead</td> <td class="hd"><a class="cal_button" href="$_SERVER[PHP_SELF]?year=$nextYear&month=$nextMonth"> Next </a></td> </tr> <tr> <th class="we">Sun</th> <th class="wd">Mon</th> <th class="wd">Tue</th> <th class="wd">Wed</th> <th class="wd">Thu</th> <th class="wd">Fri</th> <th class="we">Sat</th> </tr> <tr> EOT; for ($d=0;$d<$dow1;$d++) echo "<td class=\"hd\"> </td>"; $c = $dow1; for ($d=1; $d<=$dim; $d++, $c++) { if ($c%7==0) echo "</tr><tr>"; $cl = ($c%7==5) || ($c%7==6) ? 'we' : 'wd'; $st = ($d == $today) ? "style='padding: 0px;'" : ''; echo "<td class=\"$cl\" $st>\n"; echo " $d "; $dateKey = sprintf('%04d-%02d-%02d',$currYear,$currMonth,$d); if(array_key_exists($dateKey, $entries)) { foreach($entries[$dateKey] as $entry) { echo '<div class="has-tooltip"> Event <span class="tooltip">'.$entry.'</span> </div>'; } } } while ($c++ % 7 != 0) echo '<td class=\"hd\"> </td>'; echo "</tr></table>\n"; echo '</div></div>'; ?> </body> </html> (My table is "events". Yours may be something else.) And, yes, again, I cannot say enough about how appreciative I am of the patient time and effort taken to help me and to also educate me. I'm so grateful.
  5. I just flat out love you guys. Yes.... events, not calender. My goodness. I just get so progressively foggy with all the meds they're making me take, that I absolutely never saw that. Thank you all for being so patient with me and so kind. I'm sure I'm the most annoying poster you've ever had. Will there be prizes? Check out my page! Of course, the information in the tooltip won't say "Event" but you get the idea. And I'll have to end up using another tooltip I've been testing because this one doesn't work on IOS and the other does (though not as neat). I'll have to tweak the cosmetics a bit. I just cannot thank you enough. This is the kindest forum, to date, I've sought any kind of help from.
  6. If you'll forgive one last question; if the PHP is not throwing errors, is it possible that, since the div class "tooltips" involves CSS, that perhaps something problematic with CSS might be affecting the page, once the PHP calls for that div? I've not given attention to the CSS, because the page has always loaded just fine before and I did know for sure that the PHP needed work, but now PHP is calling for that div and that's the only thing I can think of (if you agree with the validator that the PHP file is clean). I apologize again, for being a bit slow. I'm only very recently post-surgery (spine) and I tend to grow weary as the day progresses. I get a bit dense. If you'd weigh in on my CSS question, I'll try to sort it and thank you again.
  7. I went back to the code I had posted here: http://forums.phpfreaks.com/topic/290477-got-great-help-here-but-having-trouble-implementing/?do=findComment&comment=1487954 I took a fresh empty text editor and copied that code exactly as it is on that link. Then I removed the four spaces from line 76 so that the code now looks like this: <?php $conn = ($GLOBALS["___mysqli_ston"] = mysqli_connect("localhost", "user", "password", "database_")) or die('Cannot connect to the database because: ' . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false))); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="css/master.css" type="text/css" media="all"> <meta http-equiv="Content-Type" content="text/html" /> <title>Yet Another Test</title> </head> <body> <?php // calander entries. Use the date as the key (in YYYY/MM/DD format) $entries = array( '2014/8/16' => array( 'EVENT', ) , ); $currMonth = isset($_GET['month']) ? $_GET['month'] : date('n'); $currYear = isset($_GET['year']) ? $_GET['year'] : date('Y'); $today = (($currYear == date('Y')) && ($currMonth == date('n'))) ? date('j') : 0; $currMonth = sprintf('%02d', $currMonth); // pad currMonth with zero's // when using user input, always use prepared statements otherwise could lead to SQL injection attacks $stmt = $conn->prepare('SELECT startdt, description FROM calander WHERE YEAR(startdt) = ? AND MONTH(startdt) = ?'); $stmt->bind_param('ii', $currYear, $currMonth); $stmt->execute(); $stmt->bind_result($date, $description); $entries = array(); while ($stmt->fetch()) { $entries[$date][] = $description; } $prevMonth = $currMonth == 1 ? 12 : $currMonth - 1; $nextMonth = $currMonth == 12 ? 1 : $currMonth + 1; $prevYear = $currMonth == 1 ? $currYear - 1 : $currYear; $nextYear = $currMonth == 12 ? $currYear + 1 : $currYear; $day1 = mktime(0, 0, 0, $currMonth, 1, $currYear); $dim = date('t', $day1); $dayN = mktime(0, 0, 0, $currMonth, $dim, $currYear); $dow1 = (date('w', $day1) + 0) % 7; $dowN = (date('w', $dayN) + 0) % 7; $calHead = date('F Y', $day1); echo <<<EOT <div class="calwrapper"> <div class="caltitle"><h1>Calendar</h1></div> <div class="container"> <div class="fnl first"></div> <div class="adjust"></div> <div class="fnl last"></div> </div> <div class="caldisplay"> <table cellspacing="0"> <tr> <td class="hd"><a class="cal_button" href="$_SERVER[PHP_SELF]?year=$prevYear&month=$prevMonth"> Prev </a></td> <td colspan="5" class="adjust">$calHead</td> <td class="hd"><a class="cal_button" href="$_SERVER[PHP_SELF]?year=$nextYear&month=$nextMonth"> Next </a></td> </tr> <tr> <th class="we">Sun</th> <th class="wd">Mon</th> <th class="wd">Tue</th> <th class="wd">Wed</th> <th class="wd">Thu</th> <th class="wd">Fri</th> <th class="we">Sat</th> </tr> <tr> EOT; for ($d=0;$d<$dow1;$d++) echo "<td class=\"hd\"> </td>"; $c = $dow1; for ($d=1; $d<=$dim; $d++, $c++) { if ($c%7==0) echo "</tr><tr>"; $cl = ($c%7==5) || ($c%7==6) ? 'we' : 'wd'; $st = ($d == $today) ? "style='padding: 0px;'" : ''; echo "<td class=\"$cl\" $st>\n"; echo " $d "; // construct the date, this will be used to check to if the key exists in the $entries array $dateKey = sprintf('%04d-%02d-%02d',$currYear,$currMonth,$d); // check if the key exists in the $entries array if(array_key_exists($dateKey, $entries)) { // for each event, list it in a seperate tool tip foreach($entries[$dateKey] as $entry) { echo '<div class="has-tooltip"> Event <span class="tooltip">'.$entry.'</span> </div>'; } } } ?> </body> </html> The reason I edited the file before was because when I went back to look again carefully at your instructions, I noted that, although you had told me that the $entries array could be added "anywhere above line 30" in my code, you had since edited your post so that there is now no mention of adding the $entries array. Only this: Removing the $entries array caused the error to go away (although, as I said, the page wasn't fully loading). Adding it back now, of course, as you said, removing the 4 spaces has sorted the error, even though the page is still not loading as it should. The code I've just shown is exactly what I've just uploaded, with the exception of my altering my login credentials for the purposes of posting here. I apologize for trying your patience. I appreciate your help, but I understand if you'd rather I hit the bricks. Thank you.
  8. I'm not getting any errors with this: <?php $conn = ($GLOBALS["___mysqli_ston"] = mysqli_connect("localhost", "user", "password", "database_")) or die('Cannot connect to the database because: ' . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false))); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="css/master.css" type="text/css" media="all"> <meta http-equiv="Content-Type" content="text/html" /> <title>Yet Another Test</title> </head> <body> <?php $currMonth = isset($_GET['month']) ? $_GET['month'] : date('n'); $currYear = isset($_GET['year']) ? $_GET['year'] : date('Y'); $today = (($currYear == date('Y')) && ($currMonth == date('n'))) ? date('j') : 0; $currMonth = sprintf('%02d', $currMonth); // pad currMonth with zero's // when using user input, always use prepared statements otherwise could lead to SQL injection attacks $stmt = $conn->prepare('SELECT startdt, description FROM events WHERE YEAR(startdt) = ? AND MONTH(startdt) = ?'); $stmt->bind_param('ii', $currYear, $currMonth); $stmt->execute(); $currMonth = sprintf('%02d', $currMonth); // pad currMonth with zero's // when using user input, always use prepared statements otherwise could lead to SQL injection attacks $stmt = $conn->prepare('SELECT startdt, description FROM events WHERE YEAR(startdt) = ? AND MONTH(startdt) = ?'); $stmt->bind_param('ii', $currYear, $currMonth); $stmt->execute(); $prevMonth = $currMonth == 1 ? 12 : $currMonth - 1; $nextMonth = $currMonth == 12 ? 1 : $currMonth + 1; $prevYear = $currMonth == 1 ? $currYear - 1 : $currYear; $nextYear = $currMonth == 12 ? $currYear + 1 : $currYear; $day1 = mktime(0, 0, 0, $currMonth, 1, $currYear); $dim = date('t', $day1); $dayN = mktime(0, 0, 0, $currMonth, $dim, $currYear); $dow1 = (date('w', $day1) + 0) % 7; $dowN = (date('w', $dayN) + 0) % 7; $calHead = date('F Y', $day1); echo <<<EOT <div class="calwrapper"> <div class="caltitle"><h1>Calendar</h1></div> <div class="container"> <div class="fnl first"></div> <div class="adjust"></div> <div class="fnl last"></div> </div> <div class="caldisplay"> <table cellspacing="0"> <tr> <td class="hd"><a class="cal_button" href="$_SERVER[PHP_SELF]?year=$prevYear&month=$prevMonth"> Prev </a></td> <td colspan="5" class="adjust">$calHead</td> <td class="hd"><a class="cal_button" href="$_SERVER[PHP_SELF]?year=$nextYear&month=$nextMonth"> Next </a></td> </tr> <tr> <th class="we">Sun</th> <th class="wd">Mon</th> <th class="wd">Tue</th> <th class="wd">Wed</th> <th class="wd">Thu</th> <th class="wd">Fri</th> <th class="we">Sat</th> </tr> <tr> EOT; for ($d = 0; $d < $dow1; $d++) echo "<td class=\"hd\"> </td>"; $c = $dow1; for ($d = 1; $d <= $dim; $d++, $c++) { if ($c % 7 == 0) echo "</tr><tr>"; $cl = ($c % 7 == 5) || ($c % 7 == 6) ? 'we' : 'wd'; $st = ($d == $today) ? "style='padding: 0px;'" : ''; echo "<td class=\"$cl\" $st>\n"; echo " $d "; // construct the date, this will be used to check to if the key exists in the $entries array $dateKey = sprintf('%04d-%02d-%02d', $currYear, $currMonth, $d); // check if the key exists in the $entries array if (array_key_exists($dateKey, $entries)) { // for each event, list it in a seperate tool tip foreach($entries[$dateKey] as $entry) { echo '<div class="has-tooltip"> Event <span class="tooltip">' . $entry . '</span> </div>'; echo "</td>\n"; } while ($c++ % 7 != 0) echo '<td class=\"hd\"> </td>'; echo "</tr></table>\n"; echo '</div></div>'; } // close foreach } // close if ?> </body> </html> But the page is loading like this: TEST I have double-checked login credentials in case that was the issue. The page source just stops abruptly after the opening body tag: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="css/master.css" type="text/css" media="all"> <meta http-equiv="Content-Type" content="text/html" /> <title>Yet Another Test</title> </head> <body> So you'd think I'd be throwing errors?
  9. I think, after going back and carefully staring at what Ch0cu3r said, I realize that he'd edited and that I wasn't meant to include the $events array at all, at this point. That seems to have fixed the error, I believe... I'm uploading now.
  10. Hi, ginerjm, and thank you. If the count tallies correctly, would it be a case of my mismatching them, then? I also looked at this bit of code: echo '<div class="has-tooltip"> Event <span class="tooltip">'.$entry.'</span> </div>'; ...thinking that perhaps the single quotes around .$entry. were causing it, since a single quote is begun at echo '<div class but trying to use \'.$entry.\' didn't change things. I have an even count of both open and closed parentheses and curly brackets. Would I then begin trying to determine if they're simply misplaced? For instance, I wondered if this bit of code: for ($d=1; $d<=$dim; $d++, $c++) { was meant to close at the very end of the file? (Because if it is, then I need to learn why.)
  11. So sorry to reply rather than edit, but my edit function seems to be gone. I just wanted to add that I have 51 open and 51 closed parentheses and 4 open and 4 closed curly brackets. I'm reading the manual now to try to determine what else causes "end of file" errors.
  12. Thank you CroNIX! I do have so much to learn and just when I began to delve into PHP the last week or so, I was told that much of it is changing! That's a scary proposition. With changing the indentation, I'm still getting the unexpected end of file error. <?php $conn = ($GLOBALS["___mysqli_ston"] = mysqli_connect("localhost", "user", "password", "database_")) or die('Cannot connect to the database because: ' . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false))); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="css/master.css" type="text/css" media="all"> <meta http-equiv="Content-Type" content="text/html" /> <title>Yet Another Test</title> </head> <body> <?php // calander entries. Use the date as the key (in YYYY/MM/DD format) $entries = array( '2014/8/16' => array( 'EVENT', ) , ); $currMonth = isset($_GET['month']) ? $_GET['month'] : date('n'); $currYear = isset($_GET['year']) ? $_GET['year'] : date('Y'); $today = (($currYear == date('Y')) && ($currMonth == date('n'))) ? date('j') : 0; $currMonth = sprintf('%02d', $currMonth); // pad currMonth with zero's // when using user input, always use prepared statements otherwise could lead to SQL injection attacks $stmt = $conn->prepare('SELECT startdt, description FROM calander WHERE YEAR(startdt) = ? AND MONTH(startdt) = ?'); $stmt->bind_param('ii', $currYear, $currMonth); $stmt->execute(); $stmt->bind_result($date, $description); $entries = array(); while ($stmt->fetch()) { $entries[$date][] = $description; } $prevMonth = $currMonth == 1 ? 12 : $currMonth - 1; $nextMonth = $currMonth == 12 ? 1 : $currMonth + 1; $prevYear = $currMonth == 1 ? $currYear - 1 : $currYear; $nextYear = $currMonth == 12 ? $currYear + 1 : $currYear; $day1 = mktime(0, 0, 0, $currMonth, 1, $currYear); $dim = date('t', $day1); $dayN = mktime(0, 0, 0, $currMonth, $dim, $currYear); $dow1 = (date('w', $day1) + 0) % 7; $dowN = (date('w', $dayN) + 0) % 7; $calHead = date('F Y', $day1); echo <<<EOT <div class="calwrapper"> <div class="caltitle"><h1>Calendar</h1></div> <div class="container"> <div class="fnl first"></div> <div class="adjust"></div> <div class="fnl last"></div> </div> <div class="caldisplay"> <table cellspacing="0"> <tr> <td class="hd"><a class="cal_button" href="$_SERVER[PHP_SELF]?year=$prevYear&month=$prevMonth"> Prev </a></td> <td colspan="5" class="adjust">$calHead</td> <td class="hd"><a class="cal_button" href="$_SERVER[PHP_SELF]?year=$nextYear&month=$nextMonth"> Next </a></td> </tr> <tr> <th class="we">Sun</th> <th class="wd">Mon</th> <th class="wd">Tue</th> <th class="wd">Wed</th> <th class="wd">Thu</th> <th class="wd">Fri</th> <th class="we">Sat</th> </tr> <tr> EOT; for ($d=0;$d<$dow1;$d++) echo "<td class=\"hd\"> </td>"; $c = $dow1; for ($d=1; $d<=$dim; $d++, $c++) { if ($c%7==0) echo "</tr><tr>"; $cl = ($c%7==5) || ($c%7==6) ? 'we' : 'wd'; $st = ($d == $today) ? "style='padding: 0px;'" : ''; echo "<td class=\"$cl\" $st>\n"; echo " $d "; // construct the date, this will be used to check to if the key exists in the $entries array $dateKey = sprintf('%04d-%02d-%02d',$currYear,$currMonth,$d); // check if the key exists in the $entries array if(array_key_exists($dateKey, $entries)) { // for each event, list it in a seperate tool tip foreach($entries[$dateKey] as $entry) { echo '<div class="has-tooltip"> Event <span class="tooltip">'.$entry.'</span> </div>'; } } } ?> </body> </html> Am I correct that the final closing curly bracket responds to this line? for ($d=1; $d<=$dim; $d++, $c++) { The line numbers may change slightly from changing the indentation, etc., but the error always refers to the end of this line of code, (specifically, the last line of it, containing only the opening curly bracket): foreach($entries[$dateKey] as $entry) {
  13. As it exists now: <?php $conn = ($GLOBALS["___mysqli_ston"] = mysqli_connect("localhost", "user", "password", "database_")) or die('Cannot connect to the database because: ' . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false))); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="css/master.css" type="text/css" media="all"> <meta http-equiv="Content-Type" content="text/html" /> <title>Yet Another Test</title> </head> <body> <?php // calander entries. Use the date as the key (in YYYY/MM/DD format) $entries = array( '2014/8/16' => array( 'EVENT', ) , ); $currMonth = isset($_GET['month']) ? $_GET['month'] : date('n'); $currYear = isset($_GET['year']) ? $_GET['year'] : date('Y'); $today = (($currYear == date('Y')) && ($currMonth == date('n'))) ? date('j') : 0; $currMonth = sprintf('%02d', $currMonth); // pad currMonth with zero's // when using user input, always use prepared statements otherwise could lead to SQL injection attacks $stmt = $conn->prepare('SELECT startdt, description FROM calander WHERE YEAR(startdt) = ? AND MONTH(startdt) = ?'); $stmt->bind_param('ii', $currYear, $currMonth); $stmt->execute(); $stmt->bind_result($date, $description); $entries = array(); while ($stmt->fetch()) { $entries[$date][] = $description; } $prevMonth = $currMonth == 1 ? 12 : $currMonth - 1; $nextMonth = $currMonth == 12 ? 1 : $currMonth + 1; $prevYear = $currMonth == 1 ? $currYear - 1 : $currYear; $nextYear = $currMonth == 12 ? $currYear + 1 : $currYear; $day1 = mktime(0, 0, 0, $currMonth, 1, $currYear); $dim = date('t', $day1); $dayN = mktime(0, 0, 0, $currMonth, $dim, $currYear); $dow1 = (date('w', $day1) + 0) % 7; $dowN = (date('w', $dayN) + 0) % 7; $calHead = date('F Y', $day1); echo <<<EOT <div class="calwrapper"> <div class="caltitle"><h1>Calendar</h1></div> <div class="container"> <div class="fnl first"></div> <div class="adjust"></div> <div class="fnl last"></div> </div> <div class="caldisplay"> <table cellspacing="0"> <tr> <td class="hd"><a class="cal_button" href="$_SERVER[PHP_SELF]?year=$prevYear&month=$prevMonth"> Prev </a></td> <td colspan="5" class="adjust">$calHead</td> <td class="hd"><a class="cal_button" href="$_SERVER[PHP_SELF]?year=$nextYear&month=$nextMonth"> Next </a></td> </tr> <tr> <th class="we">Sun</th> <th class="wd">Mon</th> <th class="wd">Tue</th> <th class="wd">Wed</th> <th class="wd">Thu</th> <th class="wd">Fri</th> <th class="we">Sat</th> </tr> <tr> EOT; for ($d=0;$d<$dow1;$d++) echo "<td class=\"hd\"> </td>"; $c = $dow1; for ($d=1; $d<=$dim; $d++, $c++) { if ($c%7==0) echo "</tr><tr>"; $cl = ($c%7==5) || ($c%7==6) ? 'we' : 'wd'; $st = ($d == $today) ? "style='padding: 0px;'" : ''; echo "<td class=\"$cl\" $st>\n"; echo " $d "; // construct the date, this will be used to check to if the key exists in the $entries array $dateKey = sprintf('%04d-%02d-%02d',$currYear,$currMonth,$d); // check if the key exists in the $entries array if(array_key_exists($dateKey, $entries)) { // for each event, list it in a seperate tool tip foreach($entries[$dateKey] as $entry) { echo '<div class="has-tooltip"> Event <span class="tooltip">'.$entry.'</span> </div>'; } // close foreach } // close if } ?> </body> </html> I'm now getting an unexpected end of file on line 96. I would expect to see that error at the end of the file? (By that, I mean, I guess I don't see anything on line 96 that would send the message that the file had ended prematurely.)
  14. Thank you so much, Ch0cu3r. I am including the edited code and have tried to indent it correctly, because I have two unclosed curly brackets somewhere. I have tentatively put them where I thought they should go but then panicked and removed them because you have gone to such great lengths to help and I didn't want to add anything to the page without your seeing it first. There's probably nothing more annoying than people who keep clicking away and randomly changing things while someone's trying to help them. <?php $conn = ($GLOBALS["___mysqli_ston"] = mysqli_connect("localhost", "user", "password", "database_")) or die('Cannot connect to the database because: ' . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false))); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="css/master.css" type="text/css" media="all"> <meta http-equiv="Content-Type" content="text/html" /> <title>Yet Another Test</title> </head> <body> <?php // calander entries. Use the date as the key (in YYYY/MM/DD format) $entries = array( '2014/8/16' => array( 'EVENT', ) , ); $currMonth = isset($_GET['month']) ? $_GET['month'] : date('n'); $currYear = isset($_GET['year']) ? $_GET['year'] : date('Y'); $today = (($currYear == date('Y')) && ($currMonth == date('n'))) ? date('j') : 0; $currMonth = sprintf('%02d', $currMonth); // pad currMonth with zero's // when using user input, always use prepared statements otherwise could lead to SQL injection attacks $stmt = $conn->prepare('SELECT startdt, description FROM calander WHERE YEAR(startdt) = ? AND MONTH(startdt) = ?'); $stmt->bind_param('ii', $currYear, $currMonth); $stmt->execute(); $stmt->bind_result($date, $description); $entries = array(); while ($stmt->fetch()) { $entries[$date][] = $description; } $prevMonth = $currMonth == 1 ? 12 : $currMonth - 1; $nextMonth = $currMonth == 12 ? 1 : $currMonth + 1; $prevYear = $currMonth == 1 ? $currYear - 1 : $currYear; $nextYear = $currMonth == 12 ? $currYear + 1 : $currYear; $day1 = mktime(0, 0, 0, $currMonth, 1, $currYear); $dim = date('t', $day1); $dayN = mktime(0, 0, 0, $currMonth, $dim, $currYear); $dow1 = (date('w', $day1) + 0) % 7; $dowN = (date('w', $dayN) + 0) % 7; $calHead = date('F Y', $day1); echo <<<EOT <div class="calwrapper"> <div class="caltitle"><h1>Calendar</h1></div> <div class="container"> <div class="fnl first"></div> <div class="adjust"></div> <div class="fnl last"></div> </div> <div class="caldisplay"> <table cellspacing="0"> <tr> <td class="hd"><a class="cal_button" href="$_SERVER[PHP_SELF]?year=$prevYear&month=$prevMonth"> Prev </a></td> <td colspan="5" class="adjust">$calHead</td> <td class="hd"><a class="cal_button" href="$_SERVER[PHP_SELF]?year=$nextYear&month=$nextMonth"> Next </a></td> </tr> <tr> <th class="we">Sun</th> <th class="wd">Mon</th> <th class="wd">Tue</th> <th class="wd">Wed</th> <th class="wd">Thu</th> <th class="wd">Fri</th> <th class="we">Sat</th> </tr> <tr> EOT; for ($d=0;$d<$dow1;$d++) echo "<td class=\"hd\"> </td>"; $c = $dow1; for ($d=1; $d<=$dim; $d++, $c++) { if ($c%7==0) echo "</tr><tr>"; $cl = ($c%7==5) || ($c%7==6) ? 'we' : 'wd'; $st = ($d == $today) ? "style='padding: 0px;'" : ''; echo "<td class=\"$cl\" $st>\n"; echo " $d "; // construct the date, this will be used to check to if the key exists in the $entries array $dateKey = sprintf('%04d-%02d-%02d',$currYear,$currMonth,$d); // check if the key exists in the $entries array if(array_key_exists($dateKey, $entries)) { // for each event, list it in a seperate tool tip foreach($entries[$dateKey] as $entry) { echo '<div class="has-tooltip"> Event <span class="tooltip">'.$entry.'</span> </div>'; } ?> </body> </html> Would you please advise as to whether I have followed your instructions correctly and perhaps guide me toward properly either closing two curly brackets or determining if I have inadvertently created two additional opening curly brackets when editing? I have 4 open and 2 closed.
  15. Thank you, mac_gyver. I had to stop and mull over the part about getting me sympathy but I think I get what you mean. I didn't realize that I was coming across that way. I just Googled and thought I'd come up with what was needed to progress on this thread so that I could receive help, since gizmola indicated that I wouldn't be able to receive assistance on deprecated code. I guess I was just trying to move things along on my end, in order to be in a position to receive help, so I'm sorry for that. Thank you for offering what you did. I admit that I'm sitting here, blinking stupidly at it (that much should be obvious to everyone) but I'll do my best to successfully do what you've said.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.