Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To 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 April 30th, 2012, 08:14 AM
Registered User
 
Join Date: Apr 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help with academic project PHP AJAX MySQL HTML5

Hi,

I am trying to access a database using the a html 5 select field for a mobile app for college. I have been trying to use the w3schools tutorial found here:
http://www.w3schools.com/php/php_ajax_database.asp

I have essentially copied the tutorial exactly but I keep getting the error:

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\ajax\getuser.php on line 25


I cant actually reproduce the tutorial without errors which is very frustrating as I need to be able to get this to work within a html 5 phonegap app. Any help would be greatly appreciated.

Many thanks
 
Old April 30th, 2012, 09:14 AM
Friend of Wrox
 
Join Date: May 2011
Posts: 125
Thanks: 0
Thanked 24 Times in 24 Posts
Default

Greetings,

There is no error handling around this line;
Code:
$result = mysql_query($sql);
so because the query is failing it's returning FALSE instead of a resource.
 
Old April 30th, 2012, 10:19 AM
Registered User
 
Join Date: Apr 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Please forgive my ignorance but I do not understand how to do this?
 
Old May 1st, 2012, 08:35 AM
Friend of Wrox
 
Join Date: May 2011
Posts: 125
Thanks: 0
Thanked 24 Times in 24 Posts
Default

Greetings,

Code:
if( !$result = mysql_query($sql) )
{
	die('There was a problem executing the query, MySQL returned:<br />Error Number: ' . mysql_errno() . '<br />Error: ' . mysql_error());
}





Similar Threads
Thread Thread Starter Forum Replies Last Post
what version of php/apatche/mysql this project was done? zoro12 BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8 0 November 24th, 2011 04:13 PM
Academic vs practical design question williamlove Access 17 March 30th, 2008 06:01 PM
Using AJax Update Panel With Project Playlist jazzcatone ASP.NET 2.0 Professional 1 July 22nd, 2007 12:35 PM
FREE: rankin project for PHP/MySQL newbies gleonard Beginning PHP 1 April 10th, 2006 10:30 AM
Help with first PHP/MySQL project bcohen Beginning PHP 6 April 29th, 2004 08:40 AM





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