Wrox Programmer Forums
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 October 20th, 2012, 09:25 PM
Registered User
Join Date: Oct 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default LEsson 20 page 264

Code is this:

$connection = @new mysqli('localhost', 'php24sql', 'hJQV8RTe5t');
if ($connection->connect_error) {
die('Connect Error: ' . $connection->connect_error);
} else {
echo 'Successful connection to MySQL';

Output on my computer is this:

connect_error) { die('Connect Error: ' . $connection->connect_error); } else { echo 'Successful connection to MySQL'; }

is something wrong with the (->) in the script?
Old October 21st, 2012, 01:31 PM
Friend of Wrox
Join Date: Sep 2005
Posts: 166
Thanks: 2
Thanked 33 Times in 33 Posts

Hi willyb,

It looks like your file isn't being interpreted as PHP by the web server. It is just coming down as plain text. Do a view source on your browser and you'll see the php tags.

This means that the browser is interpreting <?php and > as a tag, if a strangely-formed one, and so it does not show on the screen.

So make sure php is set up correctly for that site and the file extension is correct etc.

Old October 23rd, 2012, 02:58 AM
Friend of Wrox
Join Date: May 2011
Posts: 125
Thanks: 0
Thanked 24 Times in 24 Posts


Unless you have a class called 'mysqli' with a property of 'connect_error' then the code you provided above is meaningless. Try removing the @ before the new and see what error you get.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Lesson 20 Page 152 ThePromise86 BOOK: Knight's 24-Hour Trainer: Microsoft SQL Server 2008 Integration Services 1 January 26th, 2014 10:02 AM
Typo, Chapter 20 page 416 eightbits2011 BOOK: Visual Basic 2008 Programmer's Reference ISBN: 978-0-470-18262-8 3 December 16th, 2011 07:15 PM
Chapter 20 page 669 Try It Out Step 4 Frodo BOOK: Beginning Visual C# 2010 1 December 14th, 2011 05:17 PM
Errata: page 20 neutcomp BOOK: Professional WordPress Plugin Development 1 June 15th, 2011 08:21 AM
Try it out, Chapter 20, page 684, step 3 ron-bgsu BOOK: Beginning Microsoft Visual C# 2008 ISBN: 978-0-470-19135-4 0 October 28th, 2009 08:52 AM

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