Jump to content

Recommended Posts

Hi, This script runs fine and dandy on my hosting account, but i just installed apache and php5 with mysql5 or something, not sure about versions,

In my logout.php i have the following...
[code]
session_start();
$handle = $_SESSION['handle'];
$ip = $_SESSION['ip'];
session_destroy();
require("config.php");
dbconnect();
mysql_query("INSERT INTO chat_messages (message_id, member_id, handle, ip, timestamp, message, type) VALUES (NULL , '0', '$handle', '$ip', CURRENT_TIMESTAMP , '$handle has just logged out of chat', 'users') ") or die(mysql_error());
echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=http://localhost/\">";
echo "<center><b>Thank you for logging out!<br><br>Your chat session has ended!</b></center>";
exit;

[/code]

But when i run the page, it exits at dbconnect(); so i had a look at my error logs and it says..

[quote][04-Nov-2006 12:32:40] PHP Fatal error:  Cannot redeclare dbconnect() (previously declared in C:\apache2triad\htdocs\agc\members\chat\common.php:9) in C:\apache2triad\htdocs\agc\members\chat\common.php on line 13[/quote]

But im not redeclaring it! im only running the function!?
Any idea why im getting this error, or how to fix it?
Abydos
It just has my db variables and then includes the common.php

and in the common.php has.....


function dbconnect(){
global $dbhost, $dbuname, $dbpass, $dbname;
mysql_connect("$dbhost", "$dbuname", "$dbpass") or die(mysql_error());
mysql_select_db("$dbname") or die(mysql_error());

};


Anyone any idea?
[quote author=AbydosGater link=topic=113828.msg462859#msg462859 date=1162645551]
It just has my db variables and then includes the common.php

and in the common.php has.....


function dbconnect(){
global $dbhost, $dbuname, $dbpass, $dbname;
mysql_connect("$dbhost", "$dbuname", "$dbpass") or die(mysql_error());
mysql_select_db("$dbname") or die(mysql_error());

};


Anyone any idea?
[/quote]
dbconnect is a nbuiltin function in PHP. You'll want to change the name of your defined function dbconnect to sometyhing like db_connect or dbconn instead. In the following code:
[code]function dbconnect(){
      global $dbhost, $dbuname, $dbpass, $dbname;
  mysql_connect("$dbhost", "$dbuname", "$dbpass") or die(mysql_error());
  mysql_select_db("$dbname") or die(mysql_error());

};[/code]
You are redefining the dbconnect function which you cannot do.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.