Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: PHP and MySQL 24-Hour Trainer
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: PHP and MySQL 24-Hour Trainer
This is the forum to discuss the Wrox book PHP and MySQL 24-Hour Trainer by Andrea Tarr ; ISBN: 978-1-1180-6688-1
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: PHP and MySQL 24-Hour Trainer 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 Search this Thread Display Modes
  #1 (permalink)  
Old June 7th, 2012, 09:11 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Cannot Add new Contact (Lesson 22- Try it)

Hi,

I am not able to add a new contact to the database (Lesson 22 Try it; ).
I am getting fail message -
"No Contact Record Added. Unable to create record." (file: includes/classes/contact.php

I have moved on to lesson 26 and I am able to edit the existing contacts. I am not sure about the problem with adding new contact. It seems that the code for query is not working.

Since, I have downloaded the files from wrox.com, I don't know where the error lies.
Reply With Quote
  #2 (permalink)  
Old June 7th, 2012, 09:54 PM
Tarrconsulting's Avatar
Wrox Author
Points: 50, Level: 1
Points: 50, Level: 1 Points: 50, Level: 1 Points: 50, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2011
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Have you tried doing a compare with your files and the ones you downloaded to see what differences you might have? Two other things you could try would be to either use the debuggger with a breakpoint just before the places that error can get set or to throw in some var_dump()'s of the variables there. That will let you see what's going on.
Reply With Quote
  #3 (permalink)  
Old June 7th, 2012, 10:32 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the prompt response.

I am using the downloaded file and it is not working. I am running window 7 (64 bit) because of which my debugger is not working as expected. I cannot get breakpoints. I tried doing var_dump, but it is not reaching to that line. The var_dump is not being executed.


public function addRecord() {

// Verify the fields
if ($this->_verifyInput()) {

// Get the Database connection
$connection = Database::getConnection();

// Prepare the data
$query = "INSERT INTO contacts(first_name, last_name, position, email, phone)
VALUES ('" . Database::prep($this->first_name) . "',
'" . Database::prep($this->last_name) . "',
'" . Database::prep($this->position) . "',
'" . Database::prep($this->email) . "',
'" . Database::prep($this->phone) . "')";
// Run the MySQL statement

if ($connection->query($query)) {
$return = array('', 'Contact Record successfully added.');

// add success message
return $return;
} else {
// send fail message and return to contactmaint
$return = array('contactmaint', 'No Contact Record Added. Unable to create record.');
return $return;
}
} else {
// send fail message and return to contactmaint
$return = array('contactmaint', 'No Contact Record Added. Missing required information.');
return $return;
}

}


Since, I am getting the error listed in the nested if statement, I am assuming that the first IF statement <if ($this->_verifyInput())> is executed. However, var_dump() is not being executed within the IF statement.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
ch06 there is no name in "add a contact" jli08 BOOK: Professional XMPP Programming with JavaScript and jQuery 4 April 21st, 2012 01:27 AM
Imar, I want to add one extra thing to the contact form. Can you help? IceThatJaw BOOK: Beginning ASP.NET 4 : in C# and VB 6 January 15th, 2012 11:27 AM
Add Contact nileshpatel Classic ASP Components 0 March 10th, 2007 01:50 AM
Listing 22-6 bpdsmark BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 2 March 26th, 2006 01:29 PM
addhandler catch 22 roog ASP.NET 1.0 and 1.1 Professional 2 February 20th, 2006 01:01 PM



All times are GMT -4. The time now is 07:30 PM.


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