Jump to content

Airzooka

Members
  • Posts

    18
  • Joined

  • Last visited

    Never

About Airzooka

  • Birthday 02/16/1994

Profile Information

  • Gender
    Male
  • Location
    Guam

Airzooka's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Wrong forum. How do you want to randomly load the image? If you have your images in the same directory and named like "image_1.jpg", "image_2.jpg", "image_3.jpg", and so on, you could do something like this: <?php // Generate a random number $number = mt_rand(1, 3); // Change the "3" to the number of images available // Print the random image on the page, wherever you want it positioned echo '<img src="image_' . $number . '.jpg" alt="Picture!" />'; ?>
  2. If I understand you correctly: SELECT * FROM `table` WHERE (`col_a`=`col_b` AND `col_c`=`col_d`) OR (`col_1`=`col_2` AND `col_3`=`col_4`)
  3. Are you printing anything in a different file, and then starting the session? If you have something like this, that will cause this error, too: index.php <?php echo 'Oh, hi!'; include 'sessions.php'; ?> sessions.php <?php session_start(); ?>
  4. Here's a little something-something. If you want to retrieve more weekdays, change the number in the "$i < 6" part of the "for" loop to a higher number. If you want to change the format of the dates that are printed (IE, "11-06-2010" instead of "November 6, 2010"), check out this, then edit the date() function. <?php // Prepare integer representation of days of the week $dayNames = array(0 => 'Sunday', 1 => 'Monday', 2 => 'Tuesday', 3 => 'Wednesday', 4 => 'Thursday', 5 => 'Friday', 6 => 'Saturday'); // Get the current day $currentDay = date('w', time()); // Find the last 5 weekdays $counter = 1; $day = $currentDay - $counter; if ($day == -1) { $day = 6; } for ($i = 1; $i < 6; $i++) { $day = $currentDay - $counter; while ($day == 0 || $day == 6) { $counter++; $day = $currentDay - $counter; if ($day == -1) { $day = 6; } } echo date('F j, Y', strtotime('Last ' . $dayNames[$day])) . '<br />'; $counter++; } ?>
  5. Hi. If you're only worried about apostrophes: // Check if surname as one or more apostrophes if (strstr($surname, '\'')) { // Divide the surname into multiple parts, divided by apostrophes $surnameDivided = explode('\'', $surname); // Capitalize the first letter of each "part" of the surname foreach ($surnameDivided as &$part) { $part = ucfirst(strtolower($part)); } // Bring the surname together again, with apostrophes $surname = implode('\'', $surnameDivided); } // If there is not an apostrophe in the surname, // capitalize the first letter as you normally would else { $surname = ucfirst(strtolower($surname)); }
  6. Is there anything else before the session_start()? Even a space or a line-break before the "<?php" will set this error off.
  7. When the prospective user goes to [ mysite.com/register.php?refid=smithy ], check to see if refid is set (in a session, or in $_GET data), then if it is valid (Check if "smithy" is actually a user). If it is, save it in a session. If the user strays away from the registration page, the refid is saved in the session, and can be pulled into the registration script later. session_start(); // See if a refid is being given in the URL if (strlen($_GET['refid']) > 0) { $refid = $_GET['refid']; } // If there is no refid in the URL, check the session elseif (strlen($_SESSION['refid']) > 0) { $refid = $_SESSION['refid']; } // If a refid is set, check to see if the referring user exists // Take note that the registration process shouldn't stop if the user does not exist; // just a notice should be given. $sql = 'SELECT referring user, etc'; if (!$result = mysql_query($sql)) { echo 'Note: Could not check if the referring user exists.'; } elseif (mysql_num_rows($result) === 0) { echo 'Note: Referring user does not exist.'; } // The user exists else { // Write the current refid to the session. // Now, if the user strays away, the session will be checked for the most recent refid $_SESSION['refid'] = $refid; // Echo an <input> tag for the refid, for the registration form echo '<input type="hidden" name="refid" value="' . htmlspecialchars($refid) . '" />'; } // Continue the registration process
  8. Is your version of the script any different than the one you posted? If it is, post it.
  9. Okay. I think it will just return a string if one value is selected; if multiple values are selected, it will return an array. Try this: if (is_array($_POST['dataoutput'])) { $dataoutput = implode(', ', $_POST['dataoutput']); } else { $dataoutput = $_POST['dataoutput']; } // Then, do the same thing with $actionrq (copy this, and replace $dataoutput with $actionrq)
  10. Can you add... var_dump($_POST['dataoutput']); ...and tell me what it is?
  11. $dataoutput = $_POST['dataoutput']; $actionrq = $_POST['actionrq']; In a multi-select list, I believe the options a user selects is returned as an array -- not a string. If you want to get all the values in one string, do something like this: $dataoutput = implode(', ', $_POST['dataoutput']); $actionrq = implode(', ', $_POST['actionrq']);
  12. Additionally, are you sure the second argument is what you think it is? If the second argument is TRUE, the md5 digest is returned in a raw binary format.
  13. If that is everything you have in your search script ("code"), $field and $find have no values. You'll need to add this to the beginning of the script: $field = $_POST['field']; $find = $_POST['find']; If that isn't what's wrong, tell us what doesn't work. Does the query fail, or are no results returned?
  14. Is there anything else in the file that retrieves the file you want to give to the user? If you have something like this, then it might include the HTML at the top of the page, too. <html> <head> <titleOhai!</title> </head> <?php // Headers to send file, etc ?> </html>
  15. PHP dates and times can be tricky; Just remember that all times in PHP are large numbers that represent seconds. When more time has passed, the number obviously becomes larger. You can get the current time, in seconds, with time() You can change that time into a string, like "November 3, 2010, 10:21 AM", with date() You can change that string into seconds again with strtotime() Here's an example; I tried to make it as simple as possible. // Get the current time $now = time(); // Get information about the current time $currentHour = date('H', $now); // "H" returns the current hour $currentMinute = date('i', $now); // "s" returns the current minute // Determine when the next half-hour is if ($currentMinute < 30) { $nextHalfHour = date($currentHour . ':30'); // String representation $nextHalfHour = strtotime($nextHalfHour); // Turn into an integer timestamp } else { $nextHalfHour = date(($currentHour + 1) . ':00'); // String representation $nextHalfHour = strtotime($nextHalfHour); // Turn into an integer timestamp } // Find the time between the current time and the next half hour $difference = $nextHalfHour - $now; // Echo the time left echo 'There are '; echo date('G', $difference) . ' hours and '; echo date('i', $difference) . ' minutes until the next half-hour.';
×
×
  • 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.