Jump to content

complex05

Members
  • Posts

    124
  • Joined

  • Last visited

    Never

Everything posted by complex05

  1. ah good ol strtotime i didn't even think of that... let me give it a shot, thanks!
  2. Hello, I have a table for visitor parking passes. There are three columns: Start (date) Finish (date) Username (text) Passes can expire in either 1, 2 or 3 day intervals Now the problem I'm having is a user can only have a maximum of 12 days per month. My current query is this: //$count_reserves = mysql_query("SELECT id FROM visitorparking_slotdata WHERE username='$thisuser' AND DATE_FORMAT(start,'%m')='$month'"); //$count_reserves = mysql_num_rows($count_reserves); if ($count_reserves >= $maxreserves) { echo<<<endhtml You have exceeded the maximum amount of reservations ($maxreserves) by an owner for this month. Please contact management for more information. endhtml; } This doesn't work because it's giving me 12 passes instead of 12 days. I cannot use the MySQL function DateDiff because my MySQL version doesn't support it. I'm sure I have to do it in PHP using mktime but I don't know how to get a 'number of days' value. Any help is much appreciated! Thanks, Barry
  3. I always use PHP no matter what... if you find that most of the site will be in HTML, then do one of these echo<<<endhtml BULK OF HTML CODING HERE endhtml; that way if you need to print some variables in there, you don't need to toggle. And you don't have to worry about using quotes or anything, because that structure allows anything. Hope this helps! Barry
  4. Hello, I just wrote a script and used a code snippet I found on the web. $headers = "From: Web Form\r\n"; //specify MIME version 1.0 $headers .= "MIME-Version: 1.0\r\n"; //unique boundary $boundary = uniqid("HTMLDEMO"); //tell e-mail client this e-mail contains//alternate versions $headers .= "Content-Type: multipart/alternative" . "; boundary = $boundary\r\n\r\n"; //message to people with clients who don't //understand MIME $headers .= "This is a MIME encoded message.\r\n\r\n"; //plain text version of message //$headers .= "--$boundary\r\n" . // "Content-Type: text/plain; charset=ISO-8859-1\r\n" . // "Content-Transfer-Encoding: base64\r\n\r\n"; //$headers .= chunk_split(base64_encode("This is the plain text version!")); //HTML //version of message $headers .= "--$boundary\r\n" . "Content-Type: text/html; charset=ISO-8859-1\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n"; $headers .= chunk_split(base64_encode($message)); Everything works fine except one thing, at the end of the email the program generates, it adds this: µ¦åyÇ¥––?v)à‡–[)iȧ€ •«Ö•ëµÓ™ïv×jº çþ׶»µÓ™·J){ûµÝÓ­Ó¯wû¶»N)=ê¡Üºy·?ª®Êj[j)ž‰éþ×wyžØþ׶¿i¹¦µ¦yÇ––v)‡–[iÈ€••µ¢zƒ®Š~…®Š‰þvº…¢žjjzµanµ®tʶ?¢Á§‡¶±±r?zŠ‚¢ºžj­yr?º¶²‚þu?þ¶µzºj®j‚qvžº²Ÿµ²þ¶µ{r‰¶·jzµ†¢µžyy{rÊ­Šµ?6w¶ʶ?®¶—ªyºÊz¶‰Šzvz²w¶¹•~i²Š†?™¢¶ºj¯µ²§þµz¦•–u What could this be? Originally I used the code snippet found on php.net about HTML email, but for some reason it didn't work on this particular server. Any help would be greatly appreciated!~ Thanks Barry
  5. [!--quoteo(post=368106:date=Apr 24 2006, 03:29 PM:name=rab)--][div class=\'quotetop\']QUOTE(rab @ Apr 24 2006, 03:29 PM) [snapback]368106[/snapback][/div][div class=\'quotemain\'][!--quotec--] post your code, i'll try to see whats wrong. [/quote] this isn't really a php issue for say.. more of an html syntax... guess i'm a newb.
  6. Is it possible to have script.php?action=display#some_section I can't seem to get these working <a name"some_section">some section</a>. i tried using script.php#some_section?action=display and i tried script.php?action=display&#some_section NOTHING. help please :)
  7. You don't need to pull the rank from the database... just do $sql = "SELECT * FROM table ORDER BY id"; $query = mysql_query($sql); $rank = 1; while($data = mysql_fetch_array($query)) { echo $rank; rank++; } then the id isn't even important.
  8. [!--quoteo(post=361325:date=Apr 3 2006, 03:53 PM:name=toplay)--][div class=\'quotetop\']QUOTE(toplay @ Apr 3 2006, 03:53 PM) [snapback]361325[/snapback][/div][div class=\'quotemain\'][!--quotec--] You always write dates and times with whatever the server date and time is. Then when you go to display it, you subtract or add hours as needed. That's why this forum has a feature where it asks you what time zone you're in. [/quote] Is there a way to change my timezone with .htaccess or something? I know I can't change the server's time...
  9. you can change it using .htaccess... but to be honest I don't know how. look it up on google. or maybe someone else knows?
  10. bump.
  11. [!--quoteo(post=361291:date=Apr 3 2006, 02:14 PM:name=Zach Attack)--][div class=\'quotetop\']QUOTE(Zach Attack @ Apr 3 2006, 02:14 PM) [snapback]361291[/snapback][/div][div class=\'quotemain\'][!--quotec--] Oh, sorry, I guess I was unclear. I start the session at the top of every page. When the user is logging in I use the session register. Then they are redirected to the main page where I say 'Welcome $_SESSION['username']'. [/quote] I normally parse them into variables first $usrname = $_SESSION['username']; echo<<<endhtml Welcome back, $usrname endhtml; give it a shot.
  12. don't use session_register. use session_start() at the very beginning of your script.
  13. I don't have time to give the exact code for your validation, but a simple way to structure your validation is as follows: if (!$_POST['variable']) { $validate = 1; $error .= "you left some variable blank"; } if (!$_POST['variable']) { $validate = 1; $error .= "you left some variable blank"; } if (!$_POST['variable']) { $validate = 1; $error .= "you left some variable blank"; } THEN, final validation if ($validate == 1) { echo $error; } else { mysql_query("INSERT INTO users (username,pass) VALUES ('$username','$pass')"); echo("successful registration"); } That's how I typically do it, hope it helps.
  14. Is there an easy way to adjust the time for MySQL on a shared server? I could manually write into my scripts to use date(mktime()) but that would require too much work. When I enter a row, I use the now() function to timestamp the row... but since we've gone live on our shared server, we noticed that the server time is 3 hours behind ours. Is there any easy solution?? Please give me good news :)
  15. [!--quoteo(post=361277:date=Apr 3 2006, 01:43 PM:name=phpfreak101)--][div class=\'quotetop\']QUOTE(phpfreak101 @ Apr 3 2006, 01:43 PM) [snapback]361277[/snapback][/div][div class=\'quotemain\'][!--quotec--] I think you have to register the session variable first. Like: [code] session_register('first_name'); $_SESSION['first_name'] = $first_name; [/code] [/quote] just make sure you call session_start(); on all the scripts that are using the session variables and it should work. I had a similar problem when I started using sessions.
  16. Do you know any tools I can use that will find that information for me? My server's statistics is able to find that information, we use cpanel, is there some way to use the same functions or something?
  17. There should be a readme file in the zip file you downloaded....
  18. Hello, I'm building an advertising script and I need my script to find some information about the users viewing the ads. I need the following information: Browser Operating System Screen Resolution Country I tried googling this and found nothing. Anyone have any ideas?
  19. It's alright, I figured it out. Problem was I was getting data from the while() loop... however it wouldnt' run if the query returned no results. And 90% of the time, it SHOULD return 0... silly error.
  20. nobody wants to takea stap at this one?
  21. bump.
  22. don't use the * in your query just mysql_query("DELETE FROM dvd WHERE title='$title'");
  23. please try to be more clear in what you are asking. I have no idea what you are trying to do.
  24. I'm building an application for people to book guest suites in a hotel. This is the script i'm using [code]     if ($action == "input_details")     {         $query = mysql_query("SELECT suites,suitenos,maxnights,nightprice,deposit FROM gssettings WHERE id=1");         $data = mysql_fetch_array($query);         $maxnights = $data["maxnights"];         $suites = $data["suites"];         $suitenos = $data["suitenos"];         $nightprice = $data["nightprice"];         $deposit = $data["deposit"];         $suite_numbers = split(",",$suitenos);         $query = mysql_query("SELECT suiteno FROM gsdays WHERE date='$arrival'");         $check = mysql_num_rows($query);         if($check>=$suites)         {             $validate = 1;             $error = "There are no suites available on $arrival";         }         while($data = mysql_fetch_array($query))         {             if ($a==1) break;             for($i=0;$i<$suites;$i++)             {                 $suiteno = $data["suiteno"];                 if ($a==1) break;                 if ($check==0)                 {                     $use_suite = $suite_numbers[0];                 } else {                     if ($suiteno != $suite_numbers[$i])                     {                         $use_suite = $suite_numbers[$i];                         $a = 1;                     } else {                         $validate = 1;                         $error .= "There are no suites available on $arrival";                     }                     }             }         }         $departure = "$yearcheck-$monthcheck-$daycheck";         $query = mysql_query("SELECT DATEDIFF('$departure','$arrival') AS datediff");         $data = mysql_fetch_array($query);         $datedifference = $data["datediff"];         if ($datedifference > $maxnights)         {             $validate = 1;             $error .= "<li>You are only able to reserve the guest suite for $maxnights days";         }         for($i=0;$i<$datedifference;$i++)         {             list($year,$month,$day) = split("-",$arrival);             $this_date = date("Y-m-d",mktime(0,0,0,$month,$day+$i,$year));             $query = mysql_query("SELECT * FROM gsdays WHERE date='$this_date'");             $check = mysql_num_rows($query);             if ($check >= $suites)             {                 $validate = 1;                 $error .= "<li>There are no guest suites available on $this_date";             }         }         if ($validate == 1)         {             echo $error;             echo("<p><a href=\"guestsuite.php\" class=\"menu\">Click here to try again</a>");         } else {             $invoice = (($datedifference*$nightprice) + $deposit);             $invoice_show = number_format((($datedifference*$nightprice) + $deposit),2);             mysql_query("INSERT INTO gsdata (username,approved,suiteno,arrival,departure,invoice) VALUES ('$username',0,'$use_suite','$arrival','$departure','$invoice')");             for($i=0;$i<$datedifference;$i++)             {                 list($year,$month,$day) = split("-",$arrival);                 $this_date = date("Y-m-d",mktime(0,0,0,$month,$day+$i,$year));                 $query = mysql_query("SELECT id FROM gsdata ORDER BY id DESC LIMIT 1");                 $data = mysql_fetch_array($query);                 $dataid = $data["id"];                 mysql_query("INSERT INTO gsdays (suiteno,date,user,dataid) VALUES ('$use_suite','$this_date','$username','$dataid')");             }             echo<<<endhtml                 <b><center>Thank you for making your reservation</b><p>                 Your invoice total is $$invoice_show</center> endhtml;         }     } } [/code] The problem is $use_suite returns blank if there are no reservations, if there is one reservation it will use $suite_numbers[0]. Anyone see the problem?
×
×
  • 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.