AdrielGreene
04-24-2009, 05:03 PM
My goal with this site is to display a profile which members create to users outside of my login system. My file system has the main folder and within it is the login(control panel) folder, and a folder for each member. When the member registers (through the control panel) it creates a member folder that shares a name with the 'sub_domain' field in their database. When you go to the profile page in the members folder PHP looks at the containing directory and compares it to the 'sub_domain' field. It then displays their profile. As of now I receive no errors, however only the '$prac_dir' string displays in the echoes. Here is my code:
<?php
$prac_dir = basename(dirname(__FILE__));
require_once ('/home/myname/mysite.com/login/includes/config.inc.php');
require_once (MYSQL);
$q = "SELECT 'professional','private', 'contact' FROM users WHERE 'sub_domain' = '$prac_dir'";
$r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc));
$_display = mysqli_fetch_array ($r, MYSQLI_ASSOC);
echo "$_display[private]";
echo "$prac_dir";
echo "$_display[professional]";
echo "$_display[contact]";
?>
I assume that the reason the $_display[] array does not echo is because it will not properly connect to my database... but then it would display an error.
Code explanation:
This gets the name of the containing directory
$prac_dir = basename(dirname(__FILE__));
This gets the config file which associates 'MYSQL' with the mysql_connect file
require_once ('/home/myname/mysite.com/login/includes/config.inc.php');
This uses the value from the previous line
require_once (MYSQL);
These Select the fields from the database where 'sub-domain' field equals the containing directory. Then it puts them in an array.
q = "SELECT 'professional','private', 'contact' FROM users WHERE 'sub_domain' = '$prac_dir'";
$r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc));
$_display = mysqli_fetch_array ($r, MYSQLI_ASSOC);
Echo the array fields and the string from line one:
echo "$_display[private]";
echo "$prac_dir";
echo "$_display[professional]";
echo "$_display[contact]";
I will be playing around with the code for a half hour or so before my next class. After my class I'll come back and see if I can figure out my error, but right now I'm fairly stumped(I cant seem to find my error). If I figure it out I'll post asap. Any advice would be wonderful.
<?php
$prac_dir = basename(dirname(__FILE__));
require_once ('/home/myname/mysite.com/login/includes/config.inc.php');
require_once (MYSQL);
$q = "SELECT 'professional','private', 'contact' FROM users WHERE 'sub_domain' = '$prac_dir'";
$r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc));
$_display = mysqli_fetch_array ($r, MYSQLI_ASSOC);
echo "$_display[private]";
echo "$prac_dir";
echo "$_display[professional]";
echo "$_display[contact]";
?>
I assume that the reason the $_display[] array does not echo is because it will not properly connect to my database... but then it would display an error.
Code explanation:
This gets the name of the containing directory
$prac_dir = basename(dirname(__FILE__));
This gets the config file which associates 'MYSQL' with the mysql_connect file
require_once ('/home/myname/mysite.com/login/includes/config.inc.php');
This uses the value from the previous line
require_once (MYSQL);
These Select the fields from the database where 'sub-domain' field equals the containing directory. Then it puts them in an array.
q = "SELECT 'professional','private', 'contact' FROM users WHERE 'sub_domain' = '$prac_dir'";
$r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc));
$_display = mysqli_fetch_array ($r, MYSQLI_ASSOC);
Echo the array fields and the string from line one:
echo "$_display[private]";
echo "$prac_dir";
echo "$_display[professional]";
echo "$_display[contact]";
I will be playing around with the code for a half hour or so before my next class. After my class I'll come back and see if I can figure out my error, but right now I'm fairly stumped(I cant seem to find my error). If I figure it out I'll post asap. Any advice would be wonderful.