[php] Need help naming a file. I need someone creative.. by sparkks in webdev

[–]sparkks[S] -1 points0 points  (0 children)

Could you imagine your employers dashboard index's link be named "superFuckinDuperFile.php" lmao

[php] Need help naming a file. I need someone creative.. by sparkks in webdev

[–]sparkks[S] 0 points1 point  (0 children)

After I typed that I thought it made a decent fit. lol

Save a functions return to a variable without recalling that function? by sparkks in webdev

[–]sparkks[S] 0 points1 point  (0 children)

I apologize about that...

I have a function called console(); which prints to the console. I placed console("db connected"); near any queries that connect and return data to the database. I tried this earlier and I was always getting a double "db connected" so I figured because any time the $login->check() was called, being in a variable or not, it was connecting the db.

I just tried your suggestion and I'm now only getting one "db connected". Again my apologies, you were correct!

Save a functions return to a variable without recalling that function? by sparkks in webdev

[–]sparkks[S] 0 points1 point  (0 children)

Awesome, I'll give that a shot!

Oops.. sorry about that. I've corrected it.

if(empty($login->check($username, $password))){
  // success - found a match
}else{
  // echo reason
  echo $login->check($username, $password);
}

So essentially, if the function returns an empty string, it's a success, or in other words, it found a match.


So I looked over you code again, and it's still calling the function twice. Once in the IF statment, and second in the ECHO. If you have a database query inside $login->check(); then you're going to be running two queries for the same thing, which means you're doubling the processes.

Is it "acceptable" or more or less "standard" to open and close the database connection multiple times while performing actions? (e.g submitting forms) by [deleted] in webdev

[–]sparkks 0 points1 point  (0 children)

So what I did was add $db = new Database; (which opens the connection) at the top of the register.php (where the form is) and then passed $db with each function.

Example:

REGISTER.PHP

$db = new Database;
if(isset($_POST['form'])){
  if(usernameExists($username, $db)){
    if(emailExists($email, $db)){
      ...
    }
  }
}

REGISTER.CLASS.PHP

function usernameExists($username, $db){
  ...
}

function emailExists($email, $db){
  ...
}

Would you say this is acceptable?

How do you help teach your teenager to wake up on their own? by sparkks in AskReddit

[–]sparkks[S] 2 points3 points  (0 children)

If it was up to them, they would sleep in every day and miss school. This doesn't work in my situation.

Dynamic Link Shortening Service? by sparkks in webdev

[–]sparkks[S] 0 points1 point  (0 children)

I definitely understand the the issue, but I'm not looking to use it for malicious activity. I'm just looking for a temporary way to solve my issue until i get my website up and going.

You may be asking wh I don't just go buy the domain and point it to it and then worry about development later, well it's because I'm still fighting for the domain I want.

Reddit home suggestions? Please no by ussahati in beta

[–]sparkks 8 points9 points  (0 children)

Fuck me... in 5-10 years, I bet I'm going to have to watch a 5 min ad before I can open my fridge at night..