Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
can anyone tell me wats wrong with this code
Old 08-02-2010, 01:25 PM can anyone tell me wats wrong with this code
Novice Talker

Posts: 14
Name: Ali Arif
Trades: 0
PHP Code:
// db properties
define('DBHOST','host');
define('DBUSER','user');
define('DBPASS','pass');
define('DBNAME','name');

// make a connection to mysql here
$conn mysql_connect (DBHOSTDBUSERDBPASS);
$conn mysql_select_db (DBNAME);
if(!
$conn){
    die( 
"Sorry! There seems to be a problem connecting to our database.");
}
$sql mysql_query("SELECT Username, Email FROM sitelok WHERE Email='".$_SESSION['ses_slemail']."' AND Username='".$_SESSION["ses_slusername"]."' ")or die(mysql_error());
$n mysql_num_rows($sql);
if(
$n == $_SESSION['ses_slemail']){} else {
linklokShowMessage($ErrorTemplate,"The email address provided does not match the email of the logged in user<BR><BR>Click your browsers BACK button and try again.");
exit;

luvrockz is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-02-2010, 01:29 PM Re: can anyone tell me wats wrong with this code
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Is there an error message or description of the problem to go along with that code?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 08-02-2010, 01:38 PM Re: can anyone tell me wats wrong with this code
Novice Talker

Posts: 14
Name: Ali Arif
Trades: 0
i have a script called linklokurl.php which email a temporary download link to an email adress entered to a form in demoform.php..
wat i need to do is check if the entered email matches with the email of the logged in user.... do u want me to paste the code of that php files?
luvrockz is offline
Reply With Quote
View Public Profile
 
Old 08-02-2010, 01:46 PM Re: can anyone tell me wats wrong with this code
Novice Talker

Posts: 14
Name: Ali Arif
Trades: 0
if u might wanna look at those php files.. here is the linklokurl http://pastie.org/1071315

and here is the demoform
http://pastie.org/1071319
luvrockz is offline
Reply With Quote
View Public Profile
 
Old 08-03-2010, 07:56 AM Re: can anyone tell me wats wrong with this code
phpdasan's Avatar
Experienced Talker

Posts: 37
Name: Karthick B
Trades: 0
Oops.. mysql_num_rows returns number of rows retrived.. ie an integer..

your are trying to check it against a session variable which holds an mail id. so the condition will always fail in your case..

Instead try this..

if($n != 0){} else {
linklokShowMessage($ErrorTemplate,"The email address provided does not match the email of the logged in user<BR><BR>Click your browsers BACK button and try again.");
exit;
}
__________________
There is no secret ingredient.
phpdasan is offline
Reply With Quote
View Public Profile
 
Old 08-09-2010, 10:12 AM Re: can anyone tell me wats wrong with this code
Novice Talker

Posts: 14
Name: Ali Arif
Trades: 0
hey bro that doesnt solve the problem.... it still email the code to what ever email i enter... doesnt check if entered email matches with the logged in users email..
so when i paste the code u send.. here is it look like.. is there any problem....

PHP Code:
// db properties
define('DBHOST','host');
define('DBUSER','user');
define('DBPASS','pass');
define('DBNAME','name');

// make a connection to mysql here
$conn mysql_connect (DBHOSTDBUSERDBPASS);
$conn mysql_select_db (DBNAME);
if(!
$conn){
    die( 
"Sorry! There seems to be a problem connecting to our database.");
}
$sql mysql_query("SELECT Username, Email FROM sitelok WHERE Email='".$_SESSION['ses_slemail']."' AND Username='".$_SESSION["ses_slusername"]."' ")or die(mysql_error());
$n mysql_num_rows($sql);
if(
$n != 0){} else {
linklokShowMessage($ErrorTemplate,"The email address provided does not match the email of the logged in user<BR><BR>Click your browsers BACK button and try again.");
exit;

luvrockz is offline
Reply With Quote
View Public Profile
 
Old 08-10-2010, 02:22 AM Re: can anyone tell me wats wrong with this code
phpdasan's Avatar
Experienced Talker

Posts: 37
Name: Karthick B
Trades: 0
Ok, first echo the query like,

PHP Code:

$sql 
"SELECT Username,Email FROM sitelok WHERE Email='".$_SESSION['ses_slemail']."' AND Username='".$_SESSION["ses_slusername"]."'";  

echo 
$sql
query will be printed in the browser, copy the query and test it in your query browser (PhpMyAdmin etc) and see whether you get the correct result.

also check the session values

PHP Code:

echo '<PRE>';
print_r($_SESSION); 
if there is any issue, correct it and try it.
__________________
There is no secret ingredient.
phpdasan is offline
Reply With Quote
View Public Profile
 
Old 08-17-2010, 09:22 AM Re: can anyone tell me wats wrong with this code
Novice Talker

Posts: 14
Name: Ali Arif
Trades: 0
evrything works ok... i mean it prints the query.. and also the session.... but i still cant figure out why it sends mail to any email... doesnt check if it matches with the logged in users email..
luvrockz is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to can anyone tell me wats wrong with this code
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.27593 seconds with 12 queries