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:
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:<?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]"; ?>
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.
Echo the array fields and the string from line one:Code: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);
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.Code:echo "$_display[private]"; echo "$prac_dir"; echo "$_display[professional]"; echo "$_display[contact]";



Reply With Quote



Bookmarks