Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases 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 May 28th, 2005, 01:04 PM
Registered User
Join Date: May 2005
Location: Kuala Nerang, Kedah, Malaysia.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default coding

what's wrong....

$dbhost = 'localhost';
$dbusername = 'phpuser';
$default_dbname= 'mysql';


function db_connect() ?> {
    global $dbhost, $dbusername, $dbuserpassword, $default_dbname;

    $link_id = mysql_connect($dbhost, $dbusername, $dbuserpassword);
    if (!$link_id) {
        $MYSQL_ERRNO = 0;
        $MYSQL_ERROR = "Connection failed to the host $dbhost.";
        return 0;
    else if(empty($dbname) && !mysql_select_db($default_dbname)) {
        $MYSQL_ERRNO = mysql_errno();
        $MYSQL_ERROR = mysql_error();
        return 0;
    else return $link_id;

    function sql_error() {

    if(empty($MYSQL_ERROR)) {
        $MYSQL_ERRNO = mysql_errno();
        $MYSQL_ERROR = mysql_error();
    return "$MYSQL_ERRNO: $MYSQL_ERROR";

and I got this error message

Parse error: parse error, unexpected ';', expecting '{'

Reply With Quote
  #2 (permalink)  
Old May 28th, 2005, 07:40 PM
Registered User
Join Date: May 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

From what I can see, you ended your php too early. The entire function should be scripted out, rather then ending it after the "function db_connect() ?> {", the ?> should come after your "return "$MYSQL_ERRNO: $MYSQL_ERROR";", or something along those lines. As it is now, the script knows you made a function - it simply doesn't know what to do when you call it, or where the function starts.

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
Need help with coding Gini Visual Studio 2008 2 March 6th, 2009 04:14 PM
Coding Help sugunakar Classic ASP Professional 2 March 30th, 2008 04:42 PM
help with coding mastrgamr C++ Programming 15 November 10th, 2006 07:55 AM
Help coding here Scoob PHP How-To 3 January 26th, 2006 11:18 AM
can someone help me in coding this? somanchivasu Access 1 April 5th, 2004 02:41 PM

All times are GMT -4. The time now is 06:17 PM.

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