PHP
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives Mailing Lists PHP

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old June 18th, 2008, 11:11 PM
Byron
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Variables

Hi

I was wondering if this is the correct way to reference a variable from a
file that has been included inside of a function. Also just general
static/global variable usage.

For example:

Myqsql_functions.php

<?php
require("config.php")

function ach_mysqlCon()
{
static $con = mysql_connect(global
$mysql_host,$mysql_user,$mysql_pass);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
}

function ach_mysqlCloseCon()
{
if($con)
{
mysql_close($con)
}
}
?>


And the variables are defined in config.php


config.php

<?php
//Mysql vars
$mysql_host = "localhost";
$mysql_user = "user@localhost";
$mysql_pass = "";
?>


So my questions are will ach_mysqlCloseCon() recognise the $con variable
in ach_mysqlCon() as it is declared as static? will ach_mysqlCon() recognise
the variables included from config.php as they are declared global? is this
all syntax'd properly?

Also, how would I, for example, change $mysql_host from a form?

Cheers and thanks for any and all assistance.

Reply With Quote
Reply

Viewing: Web Development Archives Mailing Lists PHP > Variables


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT