Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: PHP and MySQL 24-Hour Trainer
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 7th, 2012, 09:11 PM
Registered User
 
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.
 
Old June 7th, 2012, 09:54 PM
Tarrconsulting's Avatar
Wrox Author
 
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.
 
Old June 7th, 2012, 10:32 PM
Registered User
 
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.





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.