guyfromri's Profile User Rating: -----

Reputation: 46 Craftsman
Group:
Active Members
Active Posts:
825 (0.43 per day)
Joined:
16-September 09
Profile Views:
25,984
Last Active:
User is offline Today, 01:34 AM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
Intel
Favorite Gaming Platform:
XBox
Your Car:
Hyundai
Dream Kudos:
0

Latest Visitors

Icon   guyfromri very exciting things happening for the new year -- i'm hoping all my fellow D.i.C.ers are going to support me in my endeavors :)

Posts I've Made

  1. In Topic: Multiple queries for relational database - is it too much?

    Posted 15 Dec 2014

    Thank you :) Looks like my next question is going to be in PHP about arrays. Thank you again - very helpful!
  2. In Topic: Include a file once for a series of functions?

    Posted 3 Dec 2014

    Absolutely what I needed to know. Thank you very much!!
  3. In Topic: Include a file once for a series of functions?

    Posted 3 Dec 2014

    View PostArtificialSoldier, on 03 December 2014 - 12:50 PM, said:

    No? You're not defining a variable called $db in that include file? Because in the code you show you're trying to use a variable called $db that isn't defined anywhere, which is why you're getting an error message about trying to use a method of something that is not an object.


    Oh - I feel stupid lol - I thought you meant variables as part of the actual include line.

    Yes, my included file has the right variables in place. It does work in many other pieces of the site where I'm using it directly in the functions.

    Here's how that file looks.

    <?php 
      $db_user = "root";
      $db_pass = "passwordstuff";
    	$db_mstr = "db_master";
    	$db_server = "localhost";
      $db = new PDO("mysql:host=$db_server;dbname=$db_mstr", $db_user, $db_pass);
    ?>
    
    


    Here's where I think I'm wrong. I thought when a file was included, the contents of that file were available to any subsequent scripts run as part of that php run. Should I be making the db variables global? I've also read a lot of information about why global variables are a terrible idea...just want to make sure I'm learning the right way to do things.

    Thanks again
  4. In Topic: Invalid username/password error msg is not showing.

    Posted 3 Dec 2014

    var_dump($_POST)
    
    


    Find out what the variables actually hold before the script runs and it should shed some light on your issues :)/>

    Also, are you using Ajax/jQuery to submit the form? If so, the default is GET regardless of the method of the form. Just in case
  5. In Topic: Include a file once for a series of functions?

    Posted 3 Dec 2014

    I know the path is good because I can take it and use it inside the function which works fine. I'm also not using any variables. Here's my actual code so it's more clear what I'm actually doing.

    Here's the error
    Fatal error: Call to a member function query() on a non-object in

    Here's the script file
    <?php
    	
    	include "C:/xampp/htdocs/mysite/scripts/php/db/gen_user_connect.php";
    	session_start();
    	
    	function getActiveUserCount(){
    		$Qry = $db->query("SELECT COUNT(id) AS Cnt FROM 03_user_00_main WHERE active = 1");
    		$Res = $Qry-fetch(PDO::FETCH_ASSOC);
    		return $Res['Cnt'];
    	}
    
    ?>
    
    


    Here's the file where I'm trying to use the funciton
    <?php
            include "C:/xampp/htdocs/mysite/admin/users/php/gen_scripts.php";
    	$UserCount = getActiveUserCount();
    	echo "<div class = 'Opt-L'><a href = '#'>$UserCount</a></div>";
    
    


    Thank you for the help

My Information

Member Title:
D.I.C Addict
Age:
29 years old
Birthday:
April 14, 1985
Gender:
Location:
Rhode Island
Full Name:
JM
Programming Languages:
VBA/VB6
VB.NET
HTML
CSS
PHP
Javascript
MySQL

Contact Information

E-mail:
Private
AIM:
AIM  GuyfromRI85
MSN:
MSN  jmcgovern7
Website URL:
Website URL  http://
Yahoo:
Yahoo  jpms41485

Comments

Page 1 of 1
  1. Photo

    guyfromri Icon

    06 Oct 2010 - 18:52
    thanks everyone!!!
  2. Photo

    cordwell Icon

    05 Oct 2010 - 20:03
    Congrz the Winner
    Keep it safe
  3. Photo

    DaneAU Icon

    05 Oct 2010 - 00:30
    Winner!!!
  4. Photo

    raziel_ Icon

    10 Jun 2010 - 06:32
    sup dude :)
Page 1 of 1