Jump to content

Muddy_Funster

Members
  • Posts

    3,372
  • Joined

  • Last visited

  • Days Won

    18

Posts posted by Muddy_Funster

  1. I can't see anything obviously wrong with the code that's posted.  The only thing that I notice is that you're first select to get the user level should have the table identifier in there too:

     

    WHERE users.user_id = NEW.user_id
    

    But that would throw up a "column user_id in WHERE clause is ambiguous" error if it was causing a problem, not that the column user_id does not exist in d_records.

    Maybe another member will see something I don't, but I suspect in your attempt to dumb things down for us you may have lost the syntax that is causing the actual issue.

  2. the original date string should be just as it always was, you are only using the date objects to check against each other, nothing more, the original output formatting should be unaffected, unless you are overwriting the original date variable, which you can't be doing unless the Date class has the __string() Magic Method in it (which I don't think it does).  So it shouldn't matter to your displayed date.  

     

    Barand said that as long as you are using actual date objects the string format does not matter, that only matters if doing a string comparison as it works left to right by ascii value, so April comes before January (as A is a lower ascii value than J) thus you would need to have the date in the order of Y m d for the correct order to be achieved.

     

    Dates can be tricky to get right - especially when going between MySQL, PHP and Javascript.  That's why I try to do all my date and ordering work in MySQL and then just push the string value through (hance my lack of experience in PHP date work)

  3. Hi blackdl, welcome to PHPFreaks forums.

     

    You seem to have missed out the bit where you ask your actual question.  The answer to what you did ask is "yeah, I expect someone probably could - if you gave them the relevant information" , but I don't think that's what you really came here to find out ;)

  4. Each form that is filled in will correspond to one record in the table, it's not a table by itself.

     

    You're not really giving us the information that we need to answer the question you seem to be trying to ask.

     

    Is the issue presenting the info, capturing the info or storing the info?

    What information are you looking to store (all of it, not just what's in the form) and where is it coming from?

    What relationship will this information have to other information that is already stored in your DB?

    Will you be generating the questions from data in the database or will it just be hard-coded?

     

    It's always better to tell us too much than too little, we're not familiar with your project so we need a certain level of information to provide effective replies.

  5. You also need to work out how to ask a question  :tease-03:

     

    What's the issue you are having? what's your actual code (not the pseudo you have posted)? What's the expected result and? what's the actual result? What have you tried thus-far? Do you need to check if date2 is "greater than" or do you need to check if date2 is "greater than or equal to" (because you claim one and show the other)?

     

    Oh, and welcome to the PHPFreaks Forums :)

  6. alright, I'm guessing ther is a language barrier here, but this line:

     

    $urlok = 'http://full-stream.org/{id}-{titleok}.html'; for($i=1; $i<=$nbArticle; $i++; $titleok) {
    

    is wrong.

     

    What is id?

    {titleok} should be {$titleok} 

    and a for loop only takes in 3 parameters so $titleok should not be there

     

    Other than that, I'm not sure what your question is or why you posted in the regex section.

  7.  

    You can select null from your parent and then insert it your foreign key.

     

    No they can't, because the table definitions for the parent side of the keys doesn't allow null values in the ID columns, as I mentioned already.  This means that the foreign key constraint will refuse the use of a null value in the child because it would break the referential integrity of the FK.

  8. tweaking the loop slightly should strip your last two lines, and you can add the contents to another array as well as echoing it:

     

    $fData = array();
    $cnt = count($arr)
    for($i=0;$i<$cnt-1;$i++) {
        $items = sscanf($arr[$i], '%d %s %s');
        echo $items[1] . '<br>';
        $fData[$i][] = $items[1];
    }
    ...
    var_dump($fData);
    
  9. Did you add the echo after you found that the header call wasn't working or was it always there?

     

    	
    	echo 'Your roster has been updated! <a href="members_roster.php">Click here</a> to return to your roster.';
    	
    	
    	//header("Location: members_roster.php");
    	
    	
    	exit();
    	
    
    
  10. Alright and where are we with display errors and error reporting?  If you're using a hosting provider they commonly have error logging done to a file rather than the screen, which makes sense for public facing websites, but isn't as handy for development work

  11. OK, so that covers "what should happen", what I'm asking is "what is actually happening"? Are there any error messages? does it redirect to the wrong location? does it give an empty output? have you got error checking and display errors at full and turned on? At what point does it break down? are the DB queries firing ok? 

     

    The more verbose you can be with the problem the quicker we can help you find a solution. :)

  12.  

    Another option, instead of the "active" flag is to hold "valid_from" and "valid_to" dates, then

    SELECT url FROM offerTable 
    WHERE offerCode = :oCode 
         AND CURDATE() BETWEEN valid_from AND valid_to

     

    I think we've been involved with more dates on here today than I've had with my wife! lol

     

    To keep the theme you could also add "issued date" and "redeemed date" fields which could help a lot with sales metrics later on.  :happy-04:

  13. Sure there is. I'm not sure if you want a different page per code or not, but the following is assuming different pages. First thing would be to make sure your DB is setup right so that it includes Offer Code, Status and URL.

    Then you have your script SELECT the url that is attached to the offer code

     

    SELECT url FROM offerTable WHERE offerCode = :oCode AND status = "active"

    Then sense-check the results to make sure it's a valid code and a valid response from the DB then just use the returned URL to send people where you want them to go.  It also completely removes the need for your CASE.

     

    Have a bash and let us know how you get on.

     

    Note: the Status allows you to enable and disable offer codes, but if you are doing this you would want to set up some form of persistence.

  14. assuming dt is a date field you just need to add a simple WHERE condition to your SQL

    $sql = <<<SQL
    SELECT 
      dt,
      people,
      c_fname,
      c_lname,
      c_phone,
      c_notes,
      code
    FROM 
      restaurantbooking_bookings 
    WHERE dt BETWEEN CURDATE() AND DATE_ADD(CURDATE() INTERVAL 3 DAY)
    ORDER BY dt ASC
    SQL;

    Edit: Missed that you had posted Barand - damn support calls!  ::)

×
×
  • 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.