php....again

Discussion in 'Software' started by goldfish, Jul 28, 2003.

  1. goldfish

    goldfish Lt. Sushi.DC

    Okay..... what up wid this...

    My main file...
    PHP:
    <?php
     
    include("top.php"); 
     include(
    "db_connect.php")?>
    allor <br>

    <?php
    $sql 
    'SELECT * FROM `users`';
    $result mysql_db_query($dbname,$sql,$connection) or
    die(
    "Error in query");
    // with a while loop
    // this loop will iterate as many times as there are records
    while($myrow =  mysql_fetch_array($result))
    {   
        
    $userrname =  $myrow["usrname"];
        
    $password  =  $myrow["pwd"]; 
        echo 
    "$username   ...  $password <br>";       
    }    
    mysql_free_result($result);
    ?>

    <?php include("bottom.php"); ?>
    right, my top file has all sorts of funky layout stuff, and so does the bottom file. the dbconnect has.....
    PHP:

    <?php
    function db_connect() {
    $dbuser "my user name ;)";
    $dbpass "no chance!";
    $dbname "wouldnt you like to know"
    $dbhost "localhost";

    $connection mysql_connect($dbuser$dbpass$dbname$dbhost)

    if(!
    $connection) {
      echo( 
    "Unable to connect to the database");
      exit();
    }

    else {
      
    $connected_to_db "Connected to Database";
    }

    }
    ?>
    right... the table does exist, and it has an entry in it. it dies (i.e. it echos "error in query" ) and i cant figure out why
     
  2. Vlad902

    Vlad902 Guest

    allor <br> I am guessing is something you put in there to make sure it proccesses after the includes?


    $connection = mysql_connect($dbuser, $dbpass, $dbname, $dbhost)

    Usually I do it...

    $blah = mysql_connect("localhost", $luser, $passwd);

    does mysql_select_db($dbname,$connection) or die("No DB found... f00l") Give you the error?

    In $sql try having no `s' but instead just users
     
  3. goldfish

    goldfish Lt. Sushi.DC

    hmm, okay, i fout out why it wasnt getting the query (urr, yeah.... :eek:) but now nothing comes out of my query. its got somthing to do with my while loop i think...
    PHP:
    while($myrow =  mysql_fetch_array($result))
    {   
        
    $username =  $myrow["usrname"];
        
    $password  =  $myrow["pwd"]; 
        echo 
    "$username   ...  $password <br>";       
    }    
     
  4. Vlad902

    Vlad902 Guest

    Is it usrname and pwd and not username and passwd? Just making sure :)
     
  5. goldfish

    goldfish Lt. Sushi.DC

    yep, im quite sure i got the names right ;)
    anything else you can see?
     
  6. Vlad902

    Vlad902 Guest

    try echo $username . "blah" . $password;

    EDIT: What was the prob in the first place?
     
    Last edited by a moderator: Jul 28, 2003
  7. goldfish

    goldfish Lt. Sushi.DC

  8. Vlad902

    Vlad902 Guest

    The while statement may an infinite loop... maybe that's it? didn't seem to load slowly so weird, did you make any changes to the code in the first page or is it the same?
     
  9. goldfish

    goldfish Lt. Sushi.DC

    hang on... this is the latest version of the bit thats causing the problems...

    its not the loop, i got rid of it same problem.. :(
    PHP:
    <?php
    db_connect
    ();
    $sql 'SELECT * FROM users';
    $result mysql_db_query($dbname,$sql,$connection) or
    die(
    "Error in query");

        
    $username =  $myrow["usrname"];
        
    $password  =  $myrow["pwd"]; 
       echo 
    $username "blah" $password;     
      
    mysql_free_result($result);
    exit();
     
  10. Vlad902

    Vlad902 Guest

    Yeah and you forgot to add

    $myrow = mysql_fetch_array($result)

    ;)

    Still nothing I'm guessing :/ I really gotta start working with MySQL again...
     
  11. goldfish

    goldfish Lt. Sushi.DC

    hah, yo right.....

    but yeah, still nuthin.. :(
     
  12. Vlad902

    Vlad902 Guest

    try mysql_list_tables($dbname,$connection);

    What are the results?
     
  13. goldfish

    goldfish Lt. Sushi.DC

  14. goldfish

    goldfish Lt. Sushi.DC

    Ive pinned it down to this if branch... what might be going wrong?

    PHP:
    $sql mysql_query("SELECT * FROM users WHERE usrname = '$loginuser'") or die("There was a problem in the query!");
    $numrows mysql_num_rows($sql);
    $fetch_em mysql_fetch_array($sql)

    //Here is the naughty one!!
    if($numrows != "0" md5($loginpwd) == $fetch_em["pwd"]) 
    {
    echo 
    "valid";
    }
    else {
    echo 
    "not valid";
    }
     
    Last edited: Jul 29, 2003
  15. goldfish

    goldfish Lt. Sushi.DC

    BTW that thing you told me to do, gives me this :

    Resource id #5
     
  16. goldfish

    goldfish Lt. Sushi.DC

    /me laughs insanley


    A SEMI COLON!!!!!!!!!!!!!

    asdfasdfAsdFHFDAS/FSAF,HBSA/¬!!!!]#
    runs around in circles..

    carry on...

    i dont get session variables....
    PHP:
    session_register("username");
    session_register("password");
    That declares the session variables username and password, but how do you actually SET them to somthing?
     
    Last edited: Jul 29, 2003
  17. Vlad902

    Vlad902 Guest

    This solved since there is a new post or still going at it?
     
  18. goldfish

    goldfish Lt. Sushi.DC

    yes solved, i meant to say so but slipped mind.
    uset cookies instead with the setcookie() function :) mmmm coo
    kkies
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds