Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: Beginning PHP 5.3
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning PHP 5.3
This is the forum to discuss the Wrox book Beginning PHP 5.3 by Matt Doyle; ISBN: 978-0-470-41396-8
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP 5.3 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 28th, 2011, 12:45 AM
Authorized User
Points: 216, Level: 4
Points: 216, Level: 4 Points: 216, Level: 4 Points: 216, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2011
Location: USA, OHIO
Posts: 51
Thanks: 9
Thanked 0 Times in 0 Posts
Send a message via MSN to nawar youssef
Default problem with the logic of the code

I am writing chapter codes and when I got everything ready, I tried the register script at the first time it worked fine, the problem is that :

- the script added only my username and the time (automatically),and none of
the other fields was added to the database.

- then I tried to register a new member more than 10 times, but every time I
got error told me that the Email address id already exists!!!!!! and I am sure there is email address similar in the db. so I tried a new register and I wrote in the email field just a regular name without @example.com and the same thing happen and keep telling me that the address exists.

PHP Code:
if ( member::getByEmailAddress$member->getValue"emailAddress" ) ) ) {
        
$errorMessages[] = '<p class="error">Sorry this email address is already exists!!!</p>';
    } 
this a new type of errors and I don't know where I have to chek, if any have an idea plz tell me.
thx
Reply With Quote
  #2 (permalink)  
Old October 28th, 2011, 02:50 AM
Friend of Wrox
Points: 651, Level: 9
Points: 651, Level: 9 Points: 651, Level: 9 Points: 651, Level: 9
Activity: 54%
Activity: 54% Activity: 54% Activity: 54%
 
Join Date: May 2011
Location: North East UK
Posts: 125
Thanks: 0
Thanked 24 Times in 24 Posts
Default

Greetings,

In the member class check the following method: getByEmailAddress the method will return true if the email address is in use thus giving you the error message. What check it does depends on what's in the method.
Reply With Quote
  #3 (permalink)  
Old October 28th, 2011, 10:44 PM
Authorized User
Points: 216, Level: 4
Points: 216, Level: 4 Points: 216, Level: 4 Points: 216, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2011
Location: USA, OHIO
Posts: 51
Thanks: 9
Thanked 0 Times in 0 Posts
Send a message via MSN to nawar youssef
Default login doesnot work because of the seesion

I tried to see but there is no error at the function, even I copied the getByUsername() function and pasted it, then I changed the variable and username to emailAddress, so I am sure the error not from this function.
thank you for your help.

Last edited by nawar youssef; October 28th, 2011 at 10:49 PM.
Reply With Quote
  #4 (permalink)  
Old October 29th, 2011, 10:44 AM
Friend of Wrox
Points: 651, Level: 9
Points: 651, Level: 9 Points: 651, Level: 9 Points: 651, Level: 9
Activity: 54%
Activity: 54% Activity: 54% Activity: 54%
 
Join Date: May 2011
Location: North East UK
Posts: 125
Thanks: 0
Thanked 24 Times in 24 Posts
Default

Greetings,

Well the error could be coming from the getValue method of the member class, also if the name of the POST array element is not 'emailAddress' but rather 'emailaddress' you'll also get an error. As the method will be looking for 'emailAddress' in the POST array when it will not exist.

Or put another way PHP array elements are case sensitive, example;
Code:
$tmp = array('emailAddress' => 'some@example.com', 'emailaddress' => 'somethingelse@example.com');

echo '<pre>';
print_r($tmp);
echo '</pre>';
You would think the second element would over write the first but as array elements are case sensitive you end up with 2 elements not one.

So make sure on your form your input textbox names are set to reflect what your script expects them to be.
Reply With Quote
  #5 (permalink)  
Old October 29th, 2011, 11:21 PM
Authorized User
Points: 216, Level: 4
Points: 216, Level: 4 Points: 216, Level: 4 Points: 216, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2011
Location: USA, OHIO
Posts: 51
Thanks: 9
Thanked 0 Times in 0 Posts
Send a message via MSN to nawar youssef
Default not sure if I got what does u mean !!!

for the first check, when u told me to check at the getValue func, I this is my getValue() func,
Code:
public function getValue($field) {
		if ( array_key_exists($field, $this->data) ) {
			return $this->data[$field];
	  	}else {
		   	die("Field not found!!! / getValue() function");
	  	}
	}
I got no 'emailAddress', I got the variable $field !!! in the dataObject.class.php, to make it work with any field would call the function getValue, but in the member.class.php I got no getValue even!!!!
is that a mistake ?
>>>>>>>>>>>>>
And for the code you write I did not get your point, do you want me to try the code for the solution or just is an example.?? sorry for that
Reply With Quote
  #6 (permalink)  
Old November 1st, 2011, 10:49 PM
Authorized User
Points: 216, Level: 4
Points: 216, Level: 4 Points: 216, Level: 4 Points: 216, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2011
Location: USA, OHIO
Posts: 51
Thanks: 9
Thanked 0 Times in 0 Posts
Send a message via MSN to nawar youssef
Default I did not got it, it's ok

I did not got it, I feel like I am missing something, and is not easy to figure out what is it, so I am gonna restudy chapters 13 and 14, maybe I can solve the error, and then I will post here what I got, see you.
Reply With Quote
Reply


Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
need help with the below logic/code arian29 Pro VB 6 3 March 1st, 2009 09:44 AM
Login logic problem Gizmo_Gadgethead BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 September 1st, 2006 06:32 PM
Might this be a logic error due to the code? Ben Horne Javascript 1 November 30th, 2004 07:59 PM
Problem with loop logic holdmykidney XSLT 5 July 16th, 2004 07:11 AM
Mixing Data access logic and business logic polrtex BOOK: Professional Jakarta Struts 0 December 15th, 2003 06:19 PM



All times are GMT -4. The time now is 11:14 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.