Jump to content

aschk

Staff Alumni
  • Posts

    1,245
  • Joined

  • Last visited

    Never

Posts posted by aschk

  1. Indeed, MySQL interprets anything enclosed by single quote (') as a literal. Thus you weren't actually supplying field names, merely supply strings which happened to contain the name of the field, and what was actually happening would have been that it was doing a comparison,

    e.g.

    'kind_ntf' = '$IDntfK'  => would be false

     

    So you were in fact probably doing:

    INSERT INTO notifications SET false, false, false, false, false, false, false
    

     

    Hope that clarifies it for you...

  2. Was that field created by MSSQL? i.e. a custom datatype? Because that's what it appears to be.

    If so, you will have to create a trigger (in MySQL) to generate this, or (better option) get PHP to generate an ID along the lines of what you were getting before, and insert that into the table.

  3. session_id() merely represents the cookie value for the PHP session identifier.

    As neil said, "in what way?" would you envisage using session_id() as a security measure?

    It is already partly a security measure in that the session will correlate to whatever identifier comes from the session_id()...

  4. "Thanks for the suggestion but the value and text must remain different." - why?

    If you need the text then you might as well make the value and text the same.

    What could you possibly be using the text for where the value isn't a more pertinent piece of information?

  5. Yes, because each time you iterate over $totalsx you're getting a copy of $totals, which you are then editing. You're not getting a reference to the internal $totalsx item.

    Thus you have 2 options. Set it via reference, or via full array path.

    Both are supplied below:

     

    By reference

    <?php
    
    foreach ($totalsx as $key =>&$totals ){
      $totals['total'] = "Changed value";
    }
    

     

    <?php
    
    foreach ($totalsx as $key =>$totals ){
      $totalsx[$key]['total'] = "Changed value";
    }
    

  6. Are you getting an error or just no results?

    If the latter (no results) then I suggest you look at what data you are expecting.

     

    Run the following with a static "id" value directly in MySQL to see what results you are getting.

    SELECT * FROM villages_en28 WHERE player = '< PLACE ID HERE >' AND x BETWEEN 400 AND 450 AND y BETWEEN 400 and 450
    

     

    If you get no results examine why the data doesn't match up. I suspect because there is no player with x and y between those values.

    Also consider bracketing your SQL for better clarity, e.g. ... AND (x BETWEEN 400 AND 500) AND ...

  7. What's the error message?

    What data do you have?

    What data are you expecting?

    What is your schema layout?

     

    And as a prelude to you answering the questions above i've written out your query to be more readable (and it would appear i have also corrected your problem...)

     

    SELECT u.firstname
          ,u.lastname
          ,u.contact
          ,u.address
          ,u.email
          ,v.Vid
          ,v.name
          ,v.model
          ,v.seats
    FROM user u
    INNER JOIN vehicle_dtls v ON u.ID = v.ID
    INNER JOIN tbl_busimage b ON v.Vid= b.Vid
    WHERE v.route = 'USA-NEWYORK'
    

  8. The point Daniel was attempting to make is that you don't need to use PHP at all to calculate the current month.

    Hence:

     

    <?php
    // No need to calculate current month from PHP as MySQL can do this already.
    $sql = "Select * from $DB_TBLName2 where vent_today='y' and MONTH(bundle_date) = MONTH(CURDATE())";
    
    
    

     

    The above will work just fine.

  9. A quick alteration to the function supplied by Mark is as follows:

     

    function arrayInsertAt($array,$entry,$position) {
       // At front.
       if ($position == 0){
         array_unshift($array, $entry);
         return $array;
       }
       // At end.
       if($position == count($position)){
         array_push($array, $entry);
         return $array;
       }
       // Greater than end???
       if($position > count($position)){
         $array[$position] = $entry;
         return $array;
       }
       if ($position > 0) {
          return array_merge(array_slice($array,0,$position),array($entry),array_slice($array,$position));
       }
    }
    
    $testArray = array('Peter','Stewie','Brian');
    $testArray = arrayInsertAt($array,'Lois',1);
    print_r($testArray);
    
    

  10. I would still like to point out that your database design is the prime fault here. You shouldn't be having to use eval() to process this information.

    You should have a normalised schema where you have a table containing key=>value tuples.

    e.g.

    Settings table
    ==========================
    id | key          | value
    1  | testvariable  | some text
    1  | testvariable2 | some more text
    

     

    Where the ID field if a reference to a record in your primary table.

    Thus you can do:

     

    SELECT * 
    FROM settings 
    WHERE id = 1;
    

     

    You can then place all these key=>values into an associative array.

  11. All your DNS supplier can do is point your A/CNAME records to the IP for the server.

    The webserver (apache?) has to handle the interpretation of the HTTP request into pointing to a particular directory.

    Hence you will have to tweak the virtual host config, which will require the cooperation of your current host.

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