SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 44 of 44
  1. #26
    SitePoint Addict
    Join Date
    Dec 2004
    Location
    kansas
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The $sql runs fine you can tell be replacing the if($cr > 0) with if($sql) and by running it in phpmyadmin.

    For some reason it is messing up here

    Code:
    $rs = mysql_query($sql); 
      $cr = mysql_num_rows($rs); 
    if($cr > 0) { 
    $rows = mysql_fetch_assoc($rs);
    Only problem is I don't see anything wrong with it.
    Is there another way around it?

  2. #27
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    again try this code
    PHP Code:
    $rs mysql_query($sql) or die(mysql_error()); 
      
    $cr mysql_num_rows($rs); 
    echo 
    "-$sql-$cr--";
    if(
    $cr 0) { 
    $rows mysql_fetch_assoc($rs); 
    and try to post your results, might find something useful, you have to do this debuggin tot figure out whats going on
    ---------------------------
    Errors = Improved Programming.
    My Site

  3. #28
    SitePoint Addict
    Join Date
    Dec 2004
    Location
    kansas
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alrighty, maybe we have weeded out the problem...
    The error it gives is:
    Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
    What does that mean?

  4. #29
    SitePoint Zealot sidhighwind's Avatar
    Join Date
    Aug 2003
    Location
    Indianapolis, IN
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just what it says. It can't connect to mysql. I would check to see if your mysql server is running.
    Jon Whitcraft :: It's the Bombdiggity!
    Web Applications Developer :: Zend Certified Engineer
    http://www.indycar.com

  5. #30
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    server is not running, or incorrect socket path so ,its not the query error (till now)
    ---------------------------
    Errors = Improved Programming.
    My Site

  6. #31
    SitePoint Addict
    Join Date
    Dec 2004
    Location
    kansas
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The server is running and I am logged in.
    Still says that same thing

  7. #32
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i noticed this
    PHP Code:
    <?php
    $strServer
    =""// Server IP Address 'or' Name
    $strDatabase=""// Database Name
    $strUser=""// User ID
    $strPwd=""// Password
    $strDB=mysql_connect($strServer,$struser,$strPwd);
    in this line
    $strDB=mysql_connect($strServer,$struser,$strPwd);
    $struser should be $strUser (capital U, php is case sensitive)

    try again with that
    might be the error (might not be)
    ---------------------------
    Errors = Improved Programming.
    My Site

  8. #33
    SitePoint Addict
    Join Date
    Dec 2004
    Location
    kansas
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That did it!
    It no longer gives me an error, but says
    No database selected

  9. #34
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    again the same problem
    PHP Code:
    $database=mysql_select_db("strDatabase",$strDB); 
    $database=mysql_select_db($strDatabase,$strDB);

    strDatabase is a variable not a string
    you can do this too
    $database=mysql_select_db("$strDatabase",$strDB);
    inside the quotes but still its a variable

    and to be on the safe side always do

    $con = mysql_connect('host','user','pas'') or die(mysql_error());
    mysql_select_db('dbname') or die(mysql_error());
    ---------------------------
    Errors = Improved Programming.
    My Site

  10. #35
    SitePoint Addict
    Join Date
    Dec 2004
    Location
    kansas
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am behind - I actually have this posted in 2 places - I discovered that problem a while ago. Right now I am wondering
    how I can tell it to display what it has found.
    $rs = mysql_query($sql);
    After this line in the code.

  11. #36
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can you post the code you are using at this moment
    ---------------------------
    Errors = Improved Programming.
    My Site

  12. #37
    SitePoint Addict
    Join Date
    Dec 2004
    Location
    kansas
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here you are master...

    Code:
    <?php 
    
    if($lastname == 'blanchatmfg' && $year == 'fire'){ 
    header("Location: admin.php"); 
    
    }else{
    
    $strServer="mysql12.powweb.com"; // Server IP Address 'or' Name 
    $strDatabase="blanchatmfg"; // Database Name 
    $strUser="blanchatmfg"; // User ID 
    $strPwd="firetruck"; // Password 
    
    $strDB=mysql_connect($strServer,$strUser,$strPwd) or die(mysql_error());
    
    
    session_start(); # START THE SESSION ***IMPORTANT*** 
    
    $database=mysql_select_db($strDatabase,$strDB) or die(mysql_error()); 
    
    
    
    
    $sql = "SELECT * FROM `Plow Customer Information` WHERE `LastName` = '$lastname' and `Year` = '$year'"; 
      $rs = mysql_query($sql) or die(mysql_error());
      $cr = mysql_num_rows($rs) or die(mysql_error()); 
    
    if($cr > 0) { 
    $rows = mysql_fetch_assoc($rs) or die(mysql_error()); 
    # register the fields as SESSION variables 
    # change the fields to your table 
    $_SESSION['firstname'] = $rows['FirstName']; 
    $_SESSION['lastname'] = $rows['LastName']; 
    $_SESSION['saddress'] = $rows['StreetAddress']; 
    $_SESSION['city'] = $rows['City']; 
    $_SESSION['state'] = $rows['State']; 
    $_SESSION['zip'] = $rows['Zip']; 
    $_SESSION['phone'] = $rows['Phone']; 
    $_SESSION['year'] = $rows['Year']; 
    $_SESSION['sn'] = $rows['SerialNumber']; 
    $_SESSION['descrip'] = $rows['Description']; 
    
        header("Location: infomaster.php"); 
        exit(); 
        } else { 
        header("Location: error.php"); 
        exit(); 
    } 
    }
    ?>
    When I login now, I just get a plain blank page (good or bad)?

  13. #38
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    when you login if it redirects you to infomaster.php, it means its working fine,

    on infomaster.php do this
    PHP Code:
    session_start();//have to do this on every page if you want to use session
    echo '<pre>';
    print_r($_SESSION);
    echo 
    '</pre>'
    and check the output,
    if out put is exactly what you want, then its fine
    ---------------------------
    Errors = Improved Programming.
    My Site

  14. #39
    SitePoint Addict
    Join Date
    Dec 2004
    Location
    kansas
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    YES YES YES YES
    You all are very awesome!!
    It is working - only one issue - I need to end the session when the user exits the page or is inactive too long.

  15. #40
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this can either be set in php.ini (if its your own server) or can be set via .htaccess or php ini_set functions.
    you can run the following script to check how long a session remains activated
    PHP Code:
    <?php
    phpinfo
    ();
    ?>
    and to destroy the session, in the logout page(i repeat logout page, NOT every page, because it'll destory the session totally)

    do session_destroy() and it'll destroy the session along all of its variables.

    hope that helps
    ---------------------------
    Errors = Improved Programming.
    My Site

  16. #41
    SitePoint Addict
    Join Date
    Dec 2004
    Location
    kansas
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the code on my logout button:

    Code:
    <?php
    session_destroy();
    print "<meta http-equiv=\"refresh\" content=\"0;URL=index.php\">";
    ?>
    It is not working like it should.
    Is it possible to have the users log back in after a period of inactivity?
    This would just be set on the appropriate pages.

  17. #42
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thats how it should be its just you can use header function here too
    PHP Code:
    <?php
    session_destroy
    ();
    header('Location: index.php');
    ?>
    Now, user authentication is a VAST subject, so if you are concerned about security you have to research a lot about it.

    and about inactivity, you can shorten the time of session inactivity and after that time session will expire automatically.

    hope this helps

    EDIT: you can also define your own session handle rwhich stores all the session data in database and then you can specify the time limit there whatever you want
    ---------------------------
    Errors = Improved Programming.
    My Site

  18. #43
    SitePoint Addict
    Join Date
    Dec 2004
    Location
    kansas
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how do i shorten the time of session inactivity?

  19. #44
    SitePoint Addict
    Join Date
    Dec 2004
    Location
    kansas
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is not destroying the session, when I logout and log in a different person the first person's info still shows up.
    Not cool
    Here is the url
    http://blanchatmfg.com/plows/index.php
    when you try to log in as a bogus name it takes you nowhere or to the last session, whereas it should take you to error.php.
    ?????


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •