php error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

ma5ect
Forum Commoner
Posts: 35
Joined: Wed Jun 25, 2008 8:38 am

php error

Post 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
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: php error

Post by VladSun »

Post some code ...
There are 10 types of people in this world, those who understand binary and those who don't
ma5ect
Forum Commoner
Posts: 35
Joined: Wed Jun 25, 2008 8:38 am

Re: php error

Post 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());
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: php error

Post 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.
There are 10 types of people in this world, those who understand binary and those who don't
ma5ect
Forum Commoner
Posts: 35
Joined: Wed Jun 25, 2008 8:38 am

Re: php error

Post 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";
 }
 
?>
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: php error

Post 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.
There are 10 types of people in this world, those who understand binary and those who don't
ma5ect
Forum Commoner
Posts: 35
Joined: Wed Jun 25, 2008 8:38 am

Re: php error

Post by ma5ect »

i have tried wat u suggested in your last post but stil no luck
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: php error

Post by VladSun »

What did you try (code, please) and what error ouput did you get?
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: php error

Post by papa »

Same error message?

Don't forget session_start() in the beginning of your document.
ma5ect
Forum Commoner
Posts: 35
Joined: Wed Jun 25, 2008 8:38 am

Re: php error

Post 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
ma5ect
Forum Commoner
Posts: 35
Joined: Wed Jun 25, 2008 8:38 am

Re: php error

Post by ma5ect »

also i have tested the database connection and it successfully connects showing all tables but when running website i get the errors
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: php error

Post 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.
There are 10 types of people in this world, those who understand binary and those who don't
ma5ect
Forum Commoner
Posts: 35
Joined: Wed Jun 25, 2008 8:38 am

Re: php error

Post 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
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: php error

Post by VladSun »

Did you save the file?
There are 10 types of people in this world, those who understand binary and those who don't
ma5ect
Forum Commoner
Posts: 35
Joined: Wed Jun 25, 2008 8:38 am

Re: php error

Post by ma5ect »

yep
Post Reply