Jump to content

AyKay47

Members
  • Posts

    3,281
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by AyKay47

  1. 1. "Login" isn't really an object it's a procedure and shouldn't be made into a class.

    Creating a User class and creating login method(s) for that class would be a better OOP solution.

     

    2. In the call to mysql_query() you are using variable $connection when in fact variable $conn is what holds your mysql link.

  2. 1. "Login" isn't really an object it's a procedure and shouldn't be made into a class.

    Creating a User class and creating login method(s) for that class would be a better OOP solution.

     

    2. In the call to mysql_query() you are using variable $connection when in fact variable $conn is what holds your mysql link.

  3. Besides the incorrect SQL syntax:

     

     

    I wouldn't use a $_GET value to begin form handling for various reasons.

    Instead, check either a hidden input value or an existing input value being passed to begin form handling.

    Make sure to only use the die() function during development, as it is not very user-friendly.

    Also, you should be implementing error checking logic into your code so you can see exactly what and where the problem is:

     

    $username = mysql_real_escape_string($_POST['username']);
    $password = mysql_real_escape_string($_POST['password']);
    $q = "SELECT * FROM `client` WHERE `Username`= '$username' AND `Password`= '$passLIMIT 1";
    $r = mysql_query($q);
    if(!$r)
    {
    die("SQL statement: " . $q . "<br />" . "SQL Error: " . mysql_error());
    }
    ...
    

     

    I'm also curious why you are using the MYSQL PASSWORD() function? You shouldn't be in this context.

  4. I wouldn't use a $_GET value to begin form handling for various reasons.

    Instead, check either a hidden input value or an existing input value being passed to begin form handling.

    Make sure to only use the die() function during development, as it is not very user-friendly.

    Also, you should be implementing error checking logic into your code so you can see exactly what and where the problem is:

     

    $username = mysql_real_escape_string($_POST['username']);
    $password = mysql_real_escape_string($_POST['password']);
    $q = "SELECT * FROM `client` WHERE `Username`= '$username' AND `Password`= '$passLIMIT 1";
    $r = mysql_query($q);
    if(!$r)
    {
     die("SQL statement: " . $q . "<br />" . "SQL Error: " . mysql_error());
    }
    ...
    

     

    I'm also curious why you are using the MYSQL PASSWORD() function? You shouldn't be in this context.

  5. Something like this should work for you:

     

    $emails = array(); //initialize
    $query = "SELECT * FROM mailinglist ORDER BY email";
    $result = mysql_query($query); 
    $numrows = mysql_num_rows($result); 
    while($row = mysql_fetch_array($result))
    {
     $id = $row['id'];
     $email = $row['email'];
     $links .= '<li><a href="mailto:'.$email.'">'.$email.'</a> <span class="delete"><a href="?cat=05&delete='.$id.'" onclick="return confirm(\'Are you sure you want to delete?\n This action CAN NOT be undone\')"><a></span></li>';
     $emails[] = $row['email'];
    }
    
    $list = implode("; ", $emails);

     

    Also, be sure to implement error checking logic into your code

  6. Just from the context of those two lines, a few things can be said:

     

    1. $row is already an array (What does the index "email" actually hold?)

     

    2. $emails contains a two dimensional array

     

    3. A variable that does not yet exist in the script context is being concatenated onto.

     

    We need to see ALL of the relevant code logic in order to be able to properly help you.

  7. make sure that the "id" index is set in the $_GET superglobal array before setting it's value to a variable.

     

    $id = (isset($_GET["id"])) ? intval($_GET["id"]) : false

     

    then proceed with PaulRyan's code

  8. neither of those two arrays have a string key in them

     

    "a" and "b" are both string keys.

     

    In a situation where you would need to have string keys and do not want to use a foreach loop (why not?), use a persistent naming convention for the keys so you can reference them properly inside of the loop(s). Something like this:

     

    $mArr = array(
    "number1"=>array(1, 2, 3, 4, 5),
    "number2"=>array(7, 20, 43, 44, 25)
    );
    
    $i = 0;
    $c = count($mArr);
    while($i < $c)
    {
     $index = "number" . ($i + 1);
     $j=0;
     $c2 = count($mArr[$index]);
     while($j < $c2)
     {
           echo $mArr[$index][$j] . PHP_EOL;
           $j++;
     }
    $i++;
    }

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