Jump to content

Recommended Posts

<?php

if (!isset($_SESSION))

{

session_start();

}

 

//This is supposed to be in an include file not here, i just was doing some tests

$hostname_epikcon = "myhost";

$database_epikcon = "mydb";

$username_epikcon = "myuser";

$password_epikcon = "mypass";

$epikcon = mysql_pconnect($hostname_epikcon, $username_epikcon, $password_epikcon) or trigger_error(mysql_error(),E_USER_ERROR);

//end of include file

 

function login()

{

$username=$_GET['username'];

$password=$_GET['password'];

 

//the problem is HERE if i echo the $database_epikcon var i get an empty var

 

echo $database_epikcon;

mysql_select_db($database_epikcon, $epikcon);

$LoginRS__query=sprintf("SELECT name, password FROM users WHERE name=%s AND password=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));

$LoginRS = mysql_query($LoginRS__query, $epikcon) or die(mysql_error());

$loginFoundUser = mysql_num_rows($LoginRS);

if ($loginFoundUser)

{

$_SESSION['name'] = $loginUsername;

echo 'OK';

}

else

{

echo 'errore';

}

return $LoginRS;

}

?>

Link to comment
https://forums.phpfreaks.com/topic/115975-help-with-mysql-connection/
Share on other sites

You can not echo a connection to the DB!

 

The error message you can put

$epikcon = mysql_pconnect($hostname_epikcon, $username_epikcon, $password_epikcon) or die (mysql_error());

 

So, if the program doesn't stop here, your connection is successfull.

yes, it works only outside the function... the connection is ok but when i enter the function the vars are empty, im kinda new to php but i thought the vars outside the function were publics/globals

 

mysql_select_db($database_epikcon, $epikcon); at this line i got this: mysql_select_db(); -----> error

but if i try outside the function it works...

 

maybe the only way is to pass them as params?

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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