Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-09-2012, 10:53 PM   PM User | #76
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,511
Thanks: 45
Thanked 439 Times in 428 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Quote:
Originally Posted by LearningCoder View Post
Edit:Just ran the same print_r($stmt) code through my localhost and it is also returning affected_rows -1 but it lets me login....
Quote:
Originally Posted by tangoforce View Post
As it's a select statement you should be using num_rows() not affected_rows() which is for insert, update, delete etc.
Remember what I said ? - You are still looking at affected_rows() and talking about it! You even got me following that idea and scratching my head again.

Lets stick with num_rows() and have no more mention of affected_rows() since we're not affecting anything.

Quote:
Originally Posted by LearningCoder View Post
Well it seems nowadays you're the only one who replies to me so I might have to seek a bit of advice from another forum or something because my last 2-3 threads are replied to only by yourself, no one else helps me lol.
Don't take that personally. It's true your requests for help do turn into multi-page topics but that isn't unusual, it just shows your determination to get to the bottom of it.

What it does do however is scare off those who are less experienced because they know that they're not able to support your request for help. Those are the sort of people who will purely guess at something without really understanding debugging. Generally around here once you've got a reasonably respected helper assisting you, others will leave you to it unless you miss something and its glaring them in the face. It's kind of a silent understanding between those who donate time here. There are many here who would help you - Fou-Lu, firepages, Sppokster, Inigoesdr, Lamped and ShaneC to name a few (those were taken from the mod list - but there are others who are not mods). If you've ever heard the proverb "Too many cooks spoil the broth" then you'll understand it.

Don't be put off codingforums, I'm also on sitepoint but I find it a site that is 'PR heavy'. In other words its highly advertised as the expert site but the quality of support can be a bit low sometimes. I've found that codingforums is actually a lot better.

Quote:
Originally Posted by LearningCoder View Post
This is what is being returned:

Code:
mysqli_stmt Object
(
    [affected_rows] => -1
    [insert_id] => 0
    [num_rows] => 0
    [param_count] => 2
    [field_count] => 7
    [errno] => 2014
    [error] => Commands out of sync; you can't run this command now
    [sqlstate] => HY000
    [id] => 1
)
Regards,

Lc.
Which line of code output that? - The error does have a message so I'd like you to repost your code and point out which line has the error by putting a comment in please.
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.

Last edited by tangoforce; 10-09-2012 at 10:56 PM..
tangoforce is online now   Reply With Quote
Old 10-09-2012, 11:05 PM   PM User | #77
LearningCoder
Regular Coder

 
LearningCoder's Avatar
 
Join Date: Jan 2011
Location: The Pleiades
Posts: 849
Thanks: 67
Thanked 28 Times in 28 Posts
LearningCoder is an unknown quantity at this point
Sorry I did mean num_rows...lol had affected_rows in my head..

I must say I haven't found any other forum really which has supported my questions as well as CF has which is why I frequent here. Help is always appreciated taking into account you guys don't really need to be sat there going through someone elses work, especially when it turns into a topic like mine ;p

I've just taken a look and I was checking the $stmt with print_r BEFORE executing. I printed afterwards and it seems to just be printing 0 now and not -1....I can't seem to get the error back, sorry.

Just about to put it live again and re-test it.

Will report back in 20.

Regards,

LC.
LearningCoder is offline   Reply With Quote
Old 10-10-2012, 08:20 PM   PM User | #78
LearningCoder
Regular Coder

 
LearningCoder's Avatar
 
Join Date: Jan 2011
Location: The Pleiades
Posts: 849
Thanks: 67
Thanked 28 Times in 28 Posts
LearningCoder is an unknown quantity at this point
Ok it's logging in on localhost returning num_rows and affected_rows with 1 for both.

On my live host, it is returning 0.

Does this mean a difference in versions? The select query in the login_select.php file is what it should be. I've echo'd out the password which I use to query the database just before executing the statement and it matches the correct password.

Really at a hurdle which I can't get over. I've looked over and over the code now as you know for the last 3-4 days maybe even longer. Are there any good free debugging tools that you know of?

Kind regards,

LC.
LearningCoder is offline   Reply With Quote
Old 10-10-2012, 08:58 PM   PM User | #79
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,511
Thanks: 45
Thanked 439 Times in 428 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Quote:
Originally Posted by LearningCoder View Post
Ok it's logging in on localhost returning num_rows and affected_rows with 1 for both.
Ok, thats good..

Quote:
Originally Posted by LearningCoder View Post
On my live host, it is returning 0.
Bad..

Quote:
Originally Posted by LearningCoder View Post
Does this mean a difference in versions?
Possibly but why it would make a difference I've no idea.

Quote:
Originally Posted by LearningCoder View Post
Really at a hurdle which I can't get over. I've looked over and over the code now as you know for the last 3-4 days maybe even longer. Are there any good free debugging tools that you know of?
print(), var_dump(), print_r(), x_debug (may not be installed on your host), your brain or even me via a remote connection (remember though charges apply - £20 per hour, minimum of one hour with no fix no fee).

Also you could comment out the current code (reinstate it later) and run the query through mysql instead of mysqli and see what happens. This is your best next step from my POV as it allows you to determine if the data is being matched correctly or not.
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is online now   Reply With Quote
Old 10-10-2012, 10:21 PM   PM User | #80
LearningCoder
Regular Coder

 
LearningCoder's Avatar
 
Join Date: Jan 2011
Location: The Pleiades
Posts: 849
Thanks: 67
Thanked 28 Times in 28 Posts
LearningCoder is an unknown quantity at this point
OMG i've done it...............sleeeps for a week.....

I ran a var_dump() on the password variable just after using the sha1() function, ready for the query to match the user and pass, it was returning:
Code:
string(40) "examplestring40characterslater";
I looked at the table and it was 8 or 9 characters short....Deleted user, re-registered and correct amount of characters were there and it let me login.....

About 100 hours, 50 coffees, 50 cigs, sleep deprivation and the biggest pain in my * which php has thrown my way so far....a simple var_dump() could have resolved this. I should have counted every character when comparing them before, I just went off the first 5-6 and then thought it must match.....

I feel ill after this, I thought i'd never sort it. I'm surpised I have hair I really am, I was so close to just giving up!

Thanks so much for the help and all your tips and ideas.

Kind regards,

LC.
LearningCoder is offline   Reply With Quote
Old 10-10-2012, 11:23 PM   PM User | #81
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,511
Thanks: 45
Thanked 439 Times in 428 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
You see, thats why you should check the first 3-4 and last 3-4 characters of a string when you're manually comparing them! You quite clearly told me that they matched so I ruled that out as being the problem and was looking at other things.

Now you've learned how to debug a bit better dumping stuff and examining it in detail I think you deserve a pat on the back

Well done

The only thing that does worry me.. how do you know the rest of the accounts haven't suffered the same fate? - You need to check them and make sure they're all 40 characters too.

As for giving up, I did that a few years ago on one project I was working on in delphi. It was a string termination error in a socket server I was writing. I couldn't nail the fault and gave up after many desk thumping moments. 2 years later I revisited it trying to decide wether to delete the project dir or not. Opened it up and the fault was glaring me in the face. Just goes to show that giving up isn't always necessary but taking a break can be a good thing

Still, you saved yourself some money - had you of taken me up on my offer that minimum 1hr of £20 would of been wasted - I'd have identified that fault within 5 - 10 mins!
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.

Last edited by tangoforce; 10-10-2012 at 11:26 PM..
tangoforce is online now   Reply With Quote
Old 10-10-2012, 11:32 PM   PM User | #82
LearningCoder
Regular Coder

 
LearningCoder's Avatar
 
Join Date: Jan 2011
Location: The Pleiades
Posts: 849
Thanks: 67
Thanked 28 Times in 28 Posts
LearningCoder is an unknown quantity at this point
Quote:
Originally Posted by tangoforce View Post
You see, thats why you should check the first 3-4 and last 3-4 characters of a string when you're manually comparing them! You quite clearly told me that they matched so I ruled that out as being the problem and was looking at other things.

Now you've learned how to debug a bit better dumping stuff and examining it in detail I think you deserve a pat on the back

Well done
I will bear that in mind for the future, I can't believe it took me so long to spot it...

Quote:
The only thing that does worry me.. how do you know the rest of the accounts haven't suffered the same fate? - You need to check them and make sure they're all 40 characters too.
I have only created that one dummy account. I will create 10 or so more and check everything works accordingly.

Quote:
As for giving up, I did that a few years ago on one project I was working on in delphi. It was a string termination error in a socket server I was writing. I couldn't nail the fault and gave up after many desk thumping moments. 2 years later I revisited it trying to decide wether to delete the project dir or not. Opened it up and the fault was glaring me in the face. Just goes to show that giving up isn't always necessary but taking a break can be a good thing

Still, you saved yourself some money - had you of taken me up on my offer that minimum 1hr of £20 would of been wasted - I'd have identified that fault within 5 - 10 mins!
I will take all your help on board and store it! Lol oh dear that would have REALLY done my head in!

Again thank you. I'm sure you'll hear from me again but I'll really research my issue next time before asking for help.

Kind regards,

LC.

Last edited by LearningCoder; 10-11-2012 at 04:02 PM..
LearningCoder is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 07:32 PM.


Advertisement
Log in to turn off these ads.