[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 08-26-2006, 01:03 AM   #1 (permalink)
NamePros Member
 
Join Date: Nov 2005
Posts: 66
64.00 NP$ (Donate)

nigelwong is an unknown quantity at this point


Register Globals

Hi,

I have register globals turned on, but i have a script that when a form is posted, the variables are not passed on.

In the script at the top if i just go echo $dbhost; it works.

However, if i have something like

if (!isset($var1))
{
$dblink=@mysql_connect($dbhost, $dbuser, $dbpass);
}

The variables are not passed on. Any ideas?
__________________
Free AJAX Proxy: http://www.ctrlaltproxy.com
Useful DHTML/AJAX tutorials: http://www.dhtmlsite.com
nigelwong is offline  
Old 08-26-2006, 01:29 AM   #2 (permalink)
Senior Member
 
Peter's Avatar
 
Join Date: Nov 2003
Location: Scotland
Posts: 4,900
0.60 NP$ (Donate)

Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute

Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
take the @ sign away and try again and see if any error message is displayed. If it is post it here.
Peter is offline  
Old 08-26-2006, 05:27 AM   #3 (permalink)
NamePros Member
 
Join Date: Nov 2005
Posts: 66
64.00 NP$ (Donate)

nigelwong is an unknown quantity at this point


The mysql function works, but it executes it has having no values in it. so it has an error like cannot connect with nobody@localhost (USINGPASSWORD: NO) etc.
__________________
Free AJAX Proxy: http://www.ctrlaltproxy.com
Useful DHTML/AJAX tutorials: http://www.dhtmlsite.com
nigelwong is offline  
Old 08-26-2006, 06:27 AM   #4 (permalink)
 
BillyConnite's Avatar
 
Join Date: Jul 2005
Location: Coffs H, Australia
Posts: 3,107
47.00 NP$ (Donate)

BillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant future

Wildlife Parkinson's Disease Parkinson's Disease
Hey nigel,
Try this:

PHP Code:
if (!isset($var1))
{
$dblink=@mysql_connect($_POST[dbhost], $_POST[dbuser], $_POST[dbpass]);
}
Is that what you were looking for, or am I off? lol
__________________
<?php if(1===1){ $computer="fine."; }else{ $computer="broken."; } echo "Your computer is ".$computer; ?>
BillyConnite is offline  
Old 08-26-2006, 07:10 AM   #5 (permalink)
Senior Member
 
Constantin's Avatar
 
Join Date: Jan 2006
Posts: 1,081
269.00 NP$ (Donate)

Constantin is a splendid one to beholdConstantin is a splendid one to beholdConstantin is a splendid one to beholdConstantin is a splendid one to beholdConstantin is a splendid one to beholdConstantin is a splendid one to beholdConstantin is a splendid one to behold


Try this one:

$dblink=@mysql_connect("$dbhost", "$dbuser", "$dbpass");
Constantin is offline  
Old 08-26-2006, 07:25 AM   #6 (permalink)
NPQ's PA, Slave, and On Call Coder

Technical Services


 
Eric's Avatar
 
Join Date: Mar 2005
Posts: 4,546
0.71 NP$ (Donate)

Eric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond repute

Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse
Quote:
Originally Posted by BillyConnite
Hey nigel,
Try this:

PHP Code:
if (!isset($var1))
{
$dblink=@mysql_connect($_POST[dbhost], $_POST[dbuser], $_POST[dbpass]);
}
Is that what you were looking for, or am I off? lol
^ Do not use register_globals..at all
__________________
Eric is offline  
Old 08-26-2006, 04:03 PM   #7 (permalink)
NamePros Member
 
Join Date: Nov 2005
Posts: 66
64.00 NP$ (Donate)

nigelwong is an unknown quantity at this point


I've tried substituting them with the $_POST things too, but they didn't work either =/ it's really weird.

Heres the code:
PHP Code:
<?PHP
$xinput_style
="style=\"BORDER-STYLE: solid;BORDER-COLOR: #999999; BACKGROUND-COLOR: #ffffff; BORDER-WIDTH: 1px; FONT-FAMILY: Verdana; FONT-SIZE: 8pt\"";

if(
phpversion() <= "4.0.6") { $_POST=$HTTP_POST_VARS; }
if (
$_POST['submit'])
    {
    if (
trim($_POST['db'])=="") { $e0=true; }
    if (
trim($_POST['dbhost'])=="") { $e1=true; }
    if (
trim($_POST['dbuser'])=="") { $e2=true; }
    if (
trim($_POST['dbpass'])=="") { $e3=true; }
    if (!
is_writable(str_replace("/install1.php", "", $HTTP_SERVER_VARS['PATH_TRANSLATED']))) { $e4=true; }
    
    if (!isset(
$e0)&&!isset($e1)&&!isset($e2)&&!isset($e3)&&!isset($e4))
        {
        
# --------------------------------------------------------
        
$dblink=@mysql_connect($dbhost, $dbuser, $dbpass);
        
$dbsel=@mysql_select_db($db);

        
$read_dump=@fopen("Master_DB.sql", "r");
        
$result_dump=@fread($read_dump, filesize("Master_DB.sql"));
        @
fclose($read_dump);

        
$result_dump=str_replace("`", "", $result_dump);

        
$count=substr_count($result_dump, "\n");
        
$explode=explode("\n", $result_dump);
        
$buffer="";
        for (
$i=0; $i<=($count-1); $i++)
            {
            
# Create db structure
            
if (substr($explode[$i], 0, 1)!="#")
                {
                if (
substr(trim($explode[$i]), -1)==";")
                    {
                    
$temp=str_replace(";", "", $explode[$i]);
                    
$buffer.=str_replace("\n", " ", $temp);
                    
mysql_query($buffer);
                    
$buffer="";
                    }
                else {
$buffer.=str_replace("\n", " ", $explode[$i]); }
                }
            }
__________________
Free AJAX Proxy: http://www.ctrlaltproxy.com
Useful DHTML/AJAX tutorials: http://www.dhtmlsite.com
nigelwong is offline  
Old 08-26-2006, 06:41 PM   #8 (permalink)
Senior Member
 
Peter's Avatar
 
Join Date: Nov 2003
Location: Scotland
Posts: 4,900
0.60 NP$ (Donate)

Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute

Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
just a note are you sure you are meant to be using post variables for the database connection. this poses a huge security risk if that is what you are actually doing
Peter is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 12:18 PM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85