wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
Post the code for the following function: checkPass cleanMemberSession I dont want the code that calls those functions, but code for those functions.
-
Okay. looking at your code you are using an $logged variable in side the draw_admin_menu function. Now the function wont be able to access the $logged function as it is out side of the variable scope of the function. WHat you'll want to do is define as global inside the function like so [code=php:0]global $logged;[/code] Also your parameters where in the wrong order too in your function, and you was calling your function in the wrong place. Try this: [code]<?php // Here are the list of menu options I want to call $addprofile = "- <a href=\"admin_profileform.php\">Add a new Profile</a>"; $manageprofile = "- <a href=\"admin_profilemanage.php\">Manage Profiles</a>"; $newsform = "- <a href=\"admin_profilemanage.php\">Manage Profiles</a>"; $logout = " - <a href=\"logout.php\">Logout</a>"; // Here is my admin menu calling the functions above $team = "under_7s"; $menu = $addprofile . $manageprofile . $newsform . $logout; // The draw function, so I can create a list of links and user levels instead of doing the same code repeatadly function draw_admin_menu($menu, $team) { global $logged; // define the $logged variable as global so we can access them from within the function. if($logged['username'] && $logged['level'] == $team) { $html = '<center>Welcome <b>' . $logged['username'] . '</b></center><br /><br />' . $menu . '<br /><br />'; } echo $html; } draw_admin_menu($menu, $team); ?> End of page[/code]
-
Post the function here that queries the database for when the user logs in.
-
Not with a switch no.
-
session_register('userid') does nothing but creates an emtpty (null) session called userid. If you do $_SESSION['userid'] = 'userid'; The userid session will be set to 'userid'; Is this question related to your question I was helping you the othere day with about getting the userid?
-
Yes it goes at the very top of your php scripts. However you can add it to htaccess file if you want like so: [code]php_flag arg_separator.output &[/code] That way you dont have to use ini_set. However you'll need to check with your webhost whether you can use htaccess files with your hosting account, so do allow the use of htaccess however some dont.
-
Make sure you have sessions_start(); at the to each page that uses sessions, otherwise your sessions wont load. Also session_register is depreciated. You shoud use, $_SESSION['var_name'] = 'some value';, instead.
-
You can use an if/else or if/elseif/else state in side a case clause: [code=php:0]<?php $str = TRUE; $str2 = 'TRUE'; switch($str) { case TRUE: // now check the actual type of $str if($str === $str2) { echo 'str is a string'; } else { echo 'str is not a string'; } break; } ?>[/code]
-
Call To Undefinded Function mysql_connect
wildteen88 replied to wildteen88's topic in PHP Installation and Configuration
I think your script requires the php_mysql.dll extension rather than the php_mysqli.dll extension. Also note PHP doesnt officially support Apache2.2.x. -
To check PHP is suing the correct php.ini run the phpinfo function in a php file: [code]<?php phpinfo(); ?>[/code] Now look for the [b]Configuration File (php.ini) Path[/b] line. To the right of that it should state the path of php.ini it is using. If PHP couldn't find the php.ini it will say C:\WINDOWS\php.ini, or if its found the php.ini it should state the correct path to ini file. ALso note when enabling the mysql extension, you'll need to move a file called libmysql.dll to C:\WINDOWS\ (or C:\WINNT if there is no WINDOWS folder). If PHP is not using the correct move it to the WINDOWS folder, or WINNT if WINDOWS folder doesnt exist. Also download and extract the zipped bineries version of PHP, rather the PHP installer. Extract the contents of the zip file to C:\Inetpub\wwwroot\PHP overright any existing files. The installer comes with missing files/extensions.
-
The header is a problem as the code underneath it will not run, becuase as soon as PHP see the header function, it'll force the browser to move to http://yah-inc.net. Any code underneather it will not be run.
-
To create a counter variables use this: [code]// prepare out counter variable: $i = 1; while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table print "<tr><td>{$i} - <a href='index.php?act=stats&id=" . $row['id'] . "'>"; print $row['user']; print "</a></td></tr>"; // now we increment the counter var by 1 $i++; } [/code] That produce this: 1 - [name here] 2 - [name here] 3 - [name here] etc Obiviosly name here will be replaced with the name in the database
-
Best way to create curves in PS is to use the Pen tool. When you go to create a curve click then create your next point, while you are creating your secound point hold down the left mouse button and drag the mouse to left/right to create the desired curve. Masting the Pen tool isn't easy, however if you enabl the grid it can become alittle easier to perfect a decent curve. Thats how I create curves with the pen tool.
-
Topic closed as this hasnt been replied to in 2months. logged_with_bugmenot if you want this thread reopened please post in the [url=http://www.phpfreaks.com/forums/index.php/board,11.0.html]PHPFreaks.com Questions, Comments, & Suggestions[/url] forum.
-
How do I select a single row? and another question...
wildteen88 replied to a topic in PHP Coding Help
good point there Orio. -
How do I select a single row? and another question...
wildteen88 replied to a topic in PHP Coding Help
If you want to select row 2 use this as the query: [code]$query="SELECT * FROM contactbook WHERE id='2'";[/code] That will work if the id fields is an auto incremented row. For you secound question use and order by clause opn the end of your query like so: [code]SELECT * FROM tbl_name ORDER by col_name ASC[/code] If you want to learn more about SQL Queries have a read through the SQL Tutorials over at [url=http://www.w3schools.com/sql/sql_intro.asp]w3schools.com[/url] and possibly read through the tutorials over at [url=http://www.php-mysql-tutorial.com/]php-mysql-tutorial.com/[/url] -
When the user logs in you should store the users userid, which I presume is stored in the database, in a session. Then when they when they come to the profile page use $_SESSION['userid'] to get their userid which will be uses to get there info from the database.
-
If you are using the same browser in two seperate windows on the same PC on a site that uses sessions, then the same session is going to be served for both browser windows, as you are using the same client that used that the session was created on. If you used a completly different browser say IE and FF then PHP will give each browser a seperate session. This shouldnt affect other peoples sessions that are visiting the site from a different location.
-
I dont know. How does your script work? Is the userid stored in a cookie/session?
-
Yeah when the data is called out of the database PHP/MySQL get rid of the slashes, at least it does it with me. PHP has magic_quotes_gpc disabled.
-
Myql_real_escaspe_string does the same as using addslashes, htmlspecialchars, htmlentities (with ENT_QUOTES) No you dont need to use stripslashes. PHP will remove these automatically, even if you have magic_quotes_gpc disabled. When using mysql_real_escape_string you need to be connect to MySQL to use it.
-
How is the userid passed into the script as at the moment its $userid is set to 'userid' If the user comes in the url you'll want to use $_GET['userid'] which then in the url you do this: profile.php?userid=1 change 1 to user id you want to get.
-
Remove the break; and the return; they are not needed. if you are using an if/elseif/else statment. However it'll be better if you use a switch: [code=php:0]$pg = isset($_GET['page']) ? $_GET['page'] : 'home'; switch($pg) { case 'home': include 'index.php'; break; case 'news': include 'news.php'; break; case default: echo "no such page"; break; }[/code]
-
Youll want to use $name rather than $first_name as you have setup a variable called $name which holds the value of $_SESSION['first_name'] in this block of code: [code=php:0]$username=$row['username']; $password=$row['password']; $name=$row['first_name']; // this holds the first name. $address_line1=$row['address_line1']; $address_line2=$row['address_line2']; $town=$row['town']; [/code]
-
!== compares wheather the two values are the same type not whether they are the same. Take this for example: [code=php:0]// var1 is an integer $var1 = 500; // var2 is a string $var2 = '500'; //now we compare them if($var1 !== $var2) { echo "They are not the same type!!"; } else { echo "They are the same!!"; }[/code] You'll want to use != which doesnt compare whether they are same type.