Jump to content

bluesoul

Members
  • Posts

    149
  • Joined

  • Last visited

Posts posted by bluesoul

  1. php 
    ini_set ("display_errors", "1");
    error_reporting(E_ALL);
    
    $username = $_POST['username'];
    $password = $_POST['password'];
    
    $dbh=mysql_connect ("localhost", "username", "password") or die ('I cannot connect to the database because: ' . mysql_error());
    mysql_select_db ("database");
    $query = "SELECT * FROM table WHERE username = '$username' and password = '$password'";
    $result = mysql_query($query,$dbh) or die(mysql_error());
    while($row = mysql_fetch_array($result))
    {
        $area = $row['area'];
    

     

    $_GET is typically used for variables in a query string at the end of a page.  index.php?do=foo would assign $_GET['do'] = "foo";

  2. I'm not braining very well today (I blame the weather), I meant consecutive queries.  If you don't append or die(mssql_get_last_message()) you could probably miss that message.  I read an article when I was first getting acclimated to MSSQL and it presented some really bizarre scenario that could make it not work.  I don't have the link anymore but I don't think it's anything to fret over either, lol.

  3. your use of or die() doesn't make sense in this context.  It'll still return a result, only with 0 rows, if the query is built correctly.  But your query needs to look like this:

     

    $query = "SELECT * FROM table WHERE username = '$username' and password = '$password'";
    $result = mysql_query($query,$dbh) or die(mysql_error());

  4. JavaScript is much more useful than PHP in this as you won't have to submit the page and then fool with variables and stuff.

     

    See this for form validation.

     

    Although you may be right, if javascript is turned off, anyone can submit anything to that page without having it validated.

     

    More than likely, but I've had scant luck getting PHP to pop-up validation errors on-the-fly.

     

    Either way, the OP needs to at least take a stab at making it work.

  5. <?php
       include("config.inc.php");
    
    $result = mysql_query("SELECT * FROM gallery_photos");
    $i = 0;
    While($row = mysql_fetch_array($result)){
    if($i == 3) { echo "<br />"; $i = 0; } //change 3 to however many you want per row
    echo "<a href='photos/" . $row['photo_filename'] . "'><img src='photos/tb_" . $row['photo_filename'] . "' border='1' /></a>"; 
    $i++;
    } 
    
    ?>

  6. in other word

    $query = mysql_query("SELECT * FROM fc_matches ORDER BY matchID DESC LIMIT 5") or die(mysql_error());

     

     

    See my signature and let me know what happens.

    I tried it and got

    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'foo' at line 1

     

    Well there's the problem obviously.  ;D

  7. Your php Freaks are really fast thanks you are great!!!

     

    Could you indicate where at the end to put "Order By" please or simply modify my sample code for me I really would appreciate it. Sorry but I'm new to PHP and rely on guys like you for help. Really appreciate this!!!

     

    Andy

     

    ORDER BY should be the last statement in your query, after any WHEREs.

  8. having a single salt in a configuration file

     

    How would you do that?

    What is a configuration file?

     

    You're creating a physical PHP file that has the salt as a string.  You can then include() the file as necessary and make use of the salt that way.

     

    So I could create a file called salt.php

    and salt.php could be something as simple as $salt = "some value";

    ?

     

    Absolutely.  Just make sure it's a PHP file and not plain text, so it gets processed instead of displayed to the web. (ie, salt.php and not salt.html)

  9. Right.  A good tip with mysql_error() is to look immediately before the error string it provides, which would be your comma.  Commas work in UPDATE statements across multiple fields but to qualify a search result you need to use WHERE artist='$cd_artist' AND title='$cd_title' AND...etc.

  10. Replace your query with this and rerun it and see where the error is.

     

    $result = mysql_query("SELECT *  FROM tProducts WHERE artist='$cd_artist', title='$cd_title', genre='$cd_genre', year='$cd_year', type='$cd_type'") or die(mysql_error());

     

    But, to the point, you need to replace your commas with the AND statement.

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