Jump to content

CroNiX

Staff Alumni
  • Posts

    1,469
  • Joined

  • Last visited

  • Days Won

    12

Posts posted by CroNiX

  1. Also

    $domainName=$row[DOMAINS];

     

    1) in your query you are retrieving "domains" (lowercase)

    2) It should be $row['domains'], with quotes around the array index.

     

    Further, your <option> is wrong. The format should be:

    <option value="this-is-the-value-submitted-with-the-form">Text that is displayed in the dropdown</option>

  2. I don't see anywhere that you are using $i, so what's it supposed to be doing? But yes it's hard to increment a value ($i++) if it doesn't initially have a value, so what's it supposed to increment? Maybe $i = 0; just before the loop but I still don't know what you're doing with it or if it's even needed.

     

    It could be because of the X/Y coordinates where you are inserting the text within the loop. The coordinates never change so it will just write over itself for each entry. Probably the 

    $pdf->SetY(35);

     where 35 should be incrementing by some number each time it goes through the loop so each entry will be placed on its own line.

  3. Something like that. Does it display in the PDF like you want?

     

    I'm not sure if you want this part repeating:

    $pdf->SetFillColor(192,192,192);
    $pdf->SetFont('Arial','B',10);
    $pdf->SetY(35);
    $pdf->SetX(25);
    $pdf->Cell(50,6,'Site',1,0,'C',1);
    $pdf->Cell(50,6,'Number of faults',1,0,'C',1);

    If not maybe that one should go before the while() loop. It looks like it might be a header containing "Site" and "Number of faults" so probably only want to output it once while the data repeats in the loop below it.

  4. It's because of these lines:

    while($row = mysqli_fetch_array($result_topten))
    {
      $site  = $row['site'];
      $num_faults  = $row['count'];
    }

    Think logically about what's going on here. You are rewriting/overwriting $site and $num_faults each time the loop runs. So at the end of the loop execution, $site and $num_faults will be the very last values they encountered of the result set.

     

    So you need to add the code that is adding those values to the pdf to be within that while() loop instead of after, so that each one gets added.

  5. Why do you NEED php to output that pure JS that doesn't even contain any PHP? It is totally unnecessary. Just put it in regular HTML in the HEAD of your document.

     

    You also have an extra <script> tag within a <script> tag and an extra }

    You also aren't using window.location correctly if you want to redirect. What's the replace doing? Nothing.

    <head>
    
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
    <script type="text/javascript">
    
    function redirect() {
      window.location = "http://www.something.com/";
    }
    </script>
    </head>
    <body>
      <button onclick="redirect()">Redirect</button>
    </body>
  6. What error are you getting?

     

    It seems it would be best to add a new column to your db's user table and hold the script name that you want that user to redirect to. Then when the user logs in redirect them to that page instead of in an if/else block.

     

    In your else statement above, you have a misplaced quote in the echo statement (no space between echo and first quote)

  7. And I would urge you to use PDO, or MySQLi instead of the MySQL extension. The MySQL extension has been deprecated and will be removed from PHP soon, so you'd have to rewrite everything. Might as well learn it now and become a bit more future-proof :)

  8. There was nothing (visible) in your code that actually called repostEndSelect(), so it doesn't get executed.

     

    If you had a page that only had:

    <?php
    
    echo 'outside function<br>';
    
    function repostEndSelect()
    {
      echo 'inside function';
    }

    and ran it, you would only see "outside function" as the output.

     

    If you had

    <?php
    
    echo 'outside function<br>';
    
    function repostEndSelect()
    {
      echo 'inside function';
    }
    
    repostEndSelect(); //calls your function to execute it

    Then the output would be:

    outside function

    inside function

  9. There are 2 types of mysqli functions, one for procedural coding, which you are using, and the other for OOP. See the example in the manual for procedural style.

     

    This doesn't have to do with your error, but this is also incorrect as it's using mysql function and not mysqli equivalent.

    $this->db_connect_id = mysql_pconnect($this->server, $this->user, $this->password);
×
×
  • 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.