Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP 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
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 17th, 2004, 06:27 PM
Registered User
Join Date: Jun 2003
Location: Houston, Texas, USA.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Returning a result from a db function not allowed?

Hey everybody,

Can anybody see what is wrong here? I can't get any error messages to get a clue where to start. The "new part" is the function select_result(). Can you not pass back a result? Why don't I get at least some error message? I don't even see Hello World (HTML at the bottom). Very frustrating indeed.



require_once("/home/mysite/db/dbDefinitions.inc"); // ;)

 function db_connect()
    global $db_host, $db_user, $db_pwd, $db_name;
    $link_id = mysql_connect($db_host,$db_user,$db_pwd);
    return $link_id;

 function select_result($strSQL){
    $link = db_connect();
    $result = mysql_query($strSQL, $link);
    return $result;

 function UID_inuse($uid){
    $result = select_result("SELECT COUNT(*) AS count FROM parent WHERE user_name='$uid'");
    $fetch = mysql_fetch_array($result,$link);
    return ($fetch['count'] == 0)?false:true;;

    echo "User ID is in use";
    echo "User ID not in use";

Hello world

Trey Carroll
Reply With Quote
  #2 (permalink)  
Old March 17th, 2004, 07:18 PM
Friend of Wrox
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts

Try adding "or die(mysql_error);" after every mysql function.

Also I noticed function UID_inuse has two ";" in a row...

Also I've heard its more reliable to open PHP with <?php and not <? but I don't remember where (or maybe it was about an older version...)



Reply With Quote
  #3 (permalink)  
Old March 17th, 2004, 07:53 PM
Registered User
Join Date: Jun 2003
Location: Houston, Texas, USA.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts

I figured it out. I haven't touched php in months and so I'm rusty. Seems like my Host had completely turned off error reporting in php.ini so I wasn't getting any clues. There are several dumb errors. You CAN return a result set from a function. Thanks for the help.

Trey Carroll
Reply With Quote

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
Query Returning Dodgy Result In Distress Visual Studio 2005 4 January 12th, 2007 01:19 AM
Function not returning value civa Access 5 January 17th, 2006 03:44 AM
UDF: allowed in one DB but not another??? ea SQL Server 2000 2 January 18th, 2005 03:14 PM
Function not returning anything... goatboy Beginning PHP 2 December 1st, 2003 12:34 PM
Returning variables from a function starsol Beginning PHP 1 September 11th, 2003 12:58 PM

All times are GMT -4. The time now is 06:43 AM.

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