Page 1 of 2

php error

Posted: Wed Oct 08, 2008 5:14 am
by ma5ect
Hi ppl..


i have a website setup and a database running with it, everything works fine on my desktop pc and now i am trying to get it working on my laptop..

but i get the following error when running the website

could any1 plz suggest something

error:Warning: mysql_pconnect() expects parameter 4 to be long, string given in C:\xampp\htdocs\checklogin.php on line 9

Fatal error: in C:\xampp\htdocs\checklogin.php on line 9

many thanks

Re: php error

Posted: Wed Oct 08, 2008 5:25 am
by VladSun
Post some code ...

Re: php error

Posted: Wed Oct 08, 2008 5:25 am
by ma5ect
sure

$mysql_connect = mysql_pconnect($hostname_mysql_connect, $username_mysql_connect, $password_mysql_connect, $tblname_mysql_connect) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database_mysql_connect) or die(mysql_error());

Re: php error

Posted: Wed Oct 08, 2008 5:28 am
by VladSun
:)
Now look at this one (http://bg2.php.net/mysql_pconnect):
resource mysql_pconnect ([ string $server [, string $username [, string $password [, int $client_flags ]]]] )
and check if $tblname_mysql_connect is int.
You may do this by adding var_dump($tblname_mysql_connect); in your code and examine the output page.

Re: php error

Posted: Wed Oct 08, 2008 5:39 am
by ma5ect
i am little confused..wat part of the code needs to be altered..

checklogin file...

Code: Select all

<?
 
$hostname_mysql_connect = "localhost";
$database_mysql_connect = "website_members";
$username_mysql_connect = "root";
$password_mysql_connect = "******";
$tblname_mysql_connect ="members";
 
$mysql_connect = mysql_pconnect($hostname_mysql_connect, $username_mysql_connect, $password_mysql_connect, $tblname_mysql_connect) or trigger_error(mysql_error(),E_USER_ERROR); 
mysql_select_db($database_mysql_connect) or die(mysql_error());
 
$myusername = $_POST['myusername'];
$mypassword = $_POST['mypassword'];
 
$sql = "SELECT * FROM $tblname_mysql_connect WHERE username= '$myusername' and passwords='$mypassword'"; 
$result = mysql_query($sql) or die(mysql_error());
 
$count = mysql_num_rows($result);
 
if($count==1) {
 session_register("myusername");
 session_register("mypassword");
 header("location: login_success_welcome.php");
 }
 else {
 echo "Wrong Username or Password";
 }
 
?>

Re: php error

Posted: Wed Oct 08, 2008 5:48 am
by VladSun
The last argument you pass to mysql_pconnect appears to be a string. According to the PHP manual it should be a long integer (connection flags).
You can't use a table name before you have selected a database, so it's not possible to pass table name to the connection function.
Simply, remove the last argument of mysql_pconnect.

Re: php error

Posted: Wed Oct 08, 2008 6:11 am
by ma5ect
i have tried wat u suggested in your last post but stil no luck

Re: php error

Posted: Wed Oct 08, 2008 6:13 am
by VladSun
What did you try (code, please) and what error ouput did you get?

Re: php error

Posted: Wed Oct 08, 2008 6:16 am
by papa
Same error message?

Don't forget session_start() in the beginning of your document.

Re: php error

Posted: Wed Oct 08, 2008 6:23 am
by ma5ect
<?php
session_start();
$hostname_mysql_connect = "localhost";
$database_mysql_connect = "website_members";
$username_mysql_connect = "root";
$password_mysql_connect = "*******";
$tblname_mysql_connect = "members";

$mysql_connect = mysql_pconnect($hostname_mysql_connect, $username_mysql_connect, $password_mysql_connect, $tblname_mysql_connect) or trigger_error(mysql_error(),E_USER_ERROR);


same errror message

Warning: mysql_pconnect() expects parameter 4 to be long, string given in C:\xampp\htdocs\checklogin.php on line 9

Fatal error: in C:\xampp\htdocs\checklogin.php on line 9

Re: php error

Posted: Wed Oct 08, 2008 6:25 am
by ma5ect
also i have tested the database connection and it successfully connects showing all tables but when running website i get the errors

Re: php error

Posted: Wed Oct 08, 2008 6:30 am
by VladSun
...
VladSun wrote:The last argument you pass to mysql_pconnect appears to be a string. According to the PHP manual it should be a long integer (connection flags).
You can't use a table name before you have selected a database, so it's not possible to pass table name to the connection function.
Simply, remove the last argument of mysql_pconnect.

Re: php error

Posted: Wed Oct 08, 2008 6:38 am
by ma5ect
$mysql_connect = mysql_pconnect($hostname_mysql_connect, $username_mysql_connect, $password_mysql_connect) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database_mysql_connect) or die(mysql_error());

error:Warning: mysql_pconnect() expects parameter 4 to be long, string given in C:\xampp\htdocs\checklogin.php on line 9

Fatal error: in C:\xampp\htdocs\checklogin.php on line 9

Re: php error

Posted: Wed Oct 08, 2008 6:45 am
by VladSun
Did you save the file?

Re: php error

Posted: Wed Oct 08, 2008 6:46 am
by ma5ect
yep