
Nightasy
Members-
Posts
65 -
Joined
-
Last visited
Everything posted by Nightasy
-
I figured it out. Nevermind. natsort($files); $files = array_reverse($files, true); $files = array_values($files);
-
After doing a little fooling around with my script I discovered that although the natsort is sorting my array the way I want it to be sorted I also need it reindexed with the new sort. Using this: natsort($files); $files = array_reverse($files, true); I get this with a print_r($file): Array ( [16] => 4_Photo24.jpg [15] => 4_Photo23.jpg [14] => 4_Photo22.jpg [13] => 4_Photo21.jpg [12] => 4_Photo20.jpg [10] => 4_Photo19.jpg [9] => 4_Photo18.jpg [8] => 4_Photo17.jpg [7] => 4_Photo16.jpg [6] => 4_Photo15.jpg [5] => 4_Photo14.jpg [4] => 4_Photo13.gif [3] => 4_Photo12.jpg [2] => 4_Photo11.jpg [1] => 4_Photo10.jpg [23] => 4_Photo9.jpg [22] => 4_Photo8.jpg [21] => 4_Photo7.jpg [20] => 4_Photo6.jpg [19] => 4_Photo5.jpg [18] => 4_Photo4.jpg [17] => 4_Photo3.jpg [11] => 4_Photo2.jpg [0] => 4_Photo1.jpg ) As you can see, the numbers for the photos are in the correct reversed order. But they are not indexed in the correct order. How would I go about reindexing the new order created from the natsort?
-
Yea, I just had tried natsort($files); shortly after making this post and it seems my images are echoing out weirdly for a different reason. natsort is working but I'll have to look over my code as the images are echo'n out of the array weirdly for some other reason. Thanks for the help.
-
Greetings all, I have a script that creates an array from a folder of images. // Create Array $files = array(); if( is_dir( $thumbs_dir ) ) { if( $handle = opendir( $thumbs_dir ) ) { while( ( $file = readdir( $handle ) ) !== false ) { if( $file != "." && $file != ".." ) { array_push( $files, $file ); } } closedir( $handle ); } } If I echo this array out into a table or what have you it lists them in a strange way. 4_Photo1.jpg 4_Photo11.jpg 4_Photo12.jpg ......and so on up to 19 4_Photo2.jpg 4_Photo21.jpg 4_Photo22.jpg .....and so on up to 29 4_Photo3.jpg 4_Photo31.jpg 4_Photo32.jpg As you can see the array comes out in, well, a numeric order but a weird one. Instead of loading 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, it loads like above 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 21, 22..... How can I go about sorting this so that it comes out how one would count normally? Preferably in reverse order, counting down would be better. I tried: sort( $files, SORT_NUMERIC ); But that got really messy and threw the order all over the place. Best Regards, Nightasy
-
I managed to solve this problem by changing the if validation entirely to an isset. if( isset($files[$i]) ) { $thumbnail_image = $thumbs_dir.$file[$i]; $medium_image = $medium_dir.$file[$i]; echo '<a class="DDImage" href="'.$medium_image . $files[$i] .'" rel="enlargeimage" rev="targetdiv:loadareatest,trigger:click,preload:none,fx:reveal,link:'.$images_dir . $files[$i] .'"><img class="photo-link" src="'.$thumbnail_image . $files[$i] .'" /></a>'; } Works fine now.
-
Suppose I'll probably have to look into a different route. Not using array_splice is making the page get really long.
-
eh, I'm not even familiar with using an array_slice as I'm still learning. Not sure how to even go about doing that.
-
So, I'm playing around with pagination. The script I wrote determines how many images are in a folder, throws them into an array and then splits them up so that only 9 are displayed per page. It all works great except for that if a page doesn't have 9 images on it I get this error. Notice: Undefined offset:... blah blah blah I already know that it has to do with the array not having an existing field and I am supposed to use an isset to check that the array field even exists. But everywhere I have tried to put it, it doesn't work and actually causes none of the images to appear and only the errors. If anyone could show me what I'm doing wrong here I'd really appreciate it. // Create Array $files = array(); if( is_dir( $thumbs_dir ) ) { if( $handle = opendir( $thumbs_dir ) ) { while( ( $file = readdir( $handle ) ) !== false ) { if( $file != "." && $file != ".." ) { array_push( $files, $file ); } } closedir( $handle ); } } // Set images per page and determine total pages. $page_size = 9; $total_pages = ceil( count( $files ) / $page_size ); // Create divs. echo '<div id="centerwrapper">'; echo '<div id="left_div">'; // Determine Page and Display. if( isset( $_GET['p'] ) ) { $current_page = $_GET['p']; if( $current_page > $total_pages ) { $current_page = $total_pages; } } else { $current_page = 1; } $start = ( $current_page * $page_size ) - $page_size; // Title Gallery and display page number. echo $_SESSION['username'] . "'s Images<br>"; echo "Page " . $current_page . " of " . $total_pages . "<br><br>\n\n" ; // List page selectors. for( $j=0; $j<$total_pages; $j++ ) { $p = $j + 1; print( "<a href='?p=" . $p . "'>" . $p . "</a> " ); } echo "<br><br>"; echo "<hr>"; for( $i=$start; $i<$start + $page_size; $i++ ) { /*Verify file exists, if exists echo file.*/ if( is_file( $thumbs_dir . $files[$i] ) ) { $thumbnail_image = $thumbs_dir.$file[$i]; $medium_image = $medium_dir.$file[$i]; echo '<a class="DDImage" href="'.$medium_image . $files[$i] .'" rel="enlargeimage" rev="targetdiv:loadareatest,trigger:click,preload:none,fx:reveal,link:'.$images_dir . $files[$i] .'"><img class="photo-link" src="'.$thumbnail_image . $files[$i] .'" /></a>'; } } echo '</div>'; echo '</div>'; echo '<div id="loadareatest"></div>'; Oh and if you see a variable that's not being used it's because this is only part of the entire code that I have planned for this page. Best Regards, Nightasy
-
I got it working now. Thanks to anyone that gave this a read. I had to change the code from iframe id='' to iframe name=''
-
I did some more testing and changed line 22 to this. echo '<a href="',$images_dir.$file,'" target="inner_Iframe"><img class="photo-link" src="',$thumbnail_image,'" /></a>'; Now it works on Google Chrome but on Internet Explorer and Firefox it always opens the image in a new window instead of displaying the image inside the iframe. Anyone know why those browsers are doing this but Chrome is not. Oh and btw, Chrome is giving me this error. Resource interpreted as Document but transferred with MIME type image/jpeg: "http://localhost/picpoof/uploads/Poofer/photos/4_Photo9.jpg". It code works in Chrome but that error is coming up.
-
Heya all, So I've completed my first semester on PHP programming. I got an A, ./flex ! Anyhow, I'm trying to take what I've learned and practice with it. I ran into a bit of a road block and after spending a day trying to figure it out I decided it was time to come ask the pros 8D. I have some thumbnails inside a folder that are dynamically generated when a user visits a page. What I am trying to do with the thumbnails is have them, when clicked, change the photo inside of an iframe. Unfortunately this is not working. Well, enough gabbing. Here's the code that is the culprit of my problem. I think. <?php require ('includes/photo_functions.php'); $images_dir = "uploads/" . $_SESSION['username'] . "/photos/"; $thumbs_dir = "uploads/" . $_SESSION['username'] . "/photos/thumbs/"; $thumbs_width = 200; $images_per_row = 3; /** generate photo gallery **/ $image_files = get_files($images_dir); if(count($image_files)) { $index = 0; foreach($image_files as $index=>$file) { $index++; $thumbnail_image = $thumbs_dir.$file; if(!file_exists($thumbnail_image)) { $extension = get_file_extension($thumbnail_image); if($extension) { make_thumb($images_dir.$file,$thumbnail_image,$thumbs_width,$extension); } } echo '<a href="#null" onClick="inner_Iframe.location="',$images_dir.$file,'" class="photo-link"><img class="photo-link" src="',$thumbnail_image,'" /></a>'; if($index % $images_per_row == 0) { echo '<div class="clear"></div>'; } } echo '<div class="clear"></div>'; } else { echo '<p>There are no images in this gallery.</p>'; } ?> Any help would be appreciated. I'm hoping this is a logical error or perhaps poorly placed quotations? Best Regards, Nightasy
-
@mac_gyver - Thanks a lot. I figured it out as per your feedback and it all works great now.
-
Greetings all, I was trying to learn how to use hash to encrypt my the passwords in my database and that went all fine till I tried to create some log in scripts. The username and password always show as not matching. I'm obviously new to PHP and taking a college course on it right now. This is not an assignment, more just me fooling around trying to learn some things beyond the scope of the course. Here's the code that's not working. I know the problem is on this page here. The actual registration works like a charm and encrypts the password just fine. I just don't understand how to unencrypt that password to check if the user is using the correct password when logging in. <?php // This page defines two functions used by the login/logout process. /* This function determines an absolute URL and redirects the user there. The function takes one argument: the page to be redirected to. The argument defaults to index.php.*/ function redirect_user ($page = 'login.php') { // Start defining the URL... // URL is http:// plus the host name plus the current directory: $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); // Remove any trailing slashes: $url = rtrim($url, '/\\'); // Add the page: $url .= '/' . $page; // Redirect the user: header("Location: $url"); exit(); // Quit the script. } // End of redirect_user( ) function. /* This function validates the form data (the email address and password). * If both are present, the database is queried. * The function requires a database connection. * The function returns an array of information, including: * - a TRUE/FALSE variable indicating success * - an array of either errors or the database result*/ function check_login($connect, $username = '',$password = '') { $errors = array(); // Initialize error array. // Validate the email address: if (empty($username)) { $errors[] = 'You forgot to enter your user name.'; } else { $username = mysqli_real_escape_string($connect, trim($username)); } // Validate the password: if (empty($password)) { $errors[] = 'You forgot to enter your password.'; } else { $password = mysqli_real_escape_string($connect, trim($password)); } if (empty($errors)) { // If everything's OK. require ("includes/pwhash.php"); $pass_hash = PassHash::hash($password); $q = "SELECT guestid, username FROM memberlist WHERE username='$username' AND password='$pass_hash'"; $r = @mysqli_query ($connect, $q); // Run the query. // Check the result: if (mysqli_num_rows($r) == 1) { // Fetch the record: $row = mysqli_fetch_array ($r,MYSQLI_ASSOC); // Return true and the record: return array(true, $row); } else { // Not a match! $errors[] = 'The user name and password entered do not match those on file.'; } } // End of empty($errors) IF. // Return false and the errors: return array(false, $errors); } // End of check_login( ) function. The actual function that created the hash is here. pwhash.php <?php class PassHash { // blowfish private static $algo = '$2a'; // cost parameter private static $cost = '$10'; // mainly for internal use public static function unique_salt() { return substr(sha1(mt_rand()),0,22); } // this will be used to generate a hash public static function hash($password) { return crypt($password, self::$algo . self::$cost . '$' . self::unique_salt()); } // this will be used to compare a password against a hash public static function check_password($hash, $password) { $full_salt = substr($hash, 0, 29); $new_hash = crypt($password, $full_salt); return ($hash == $new_hash); } } ?> If anyone is willing to help and needs to see other pages let me know. I'll be happy to post them here. Sheesh, working with hashes makes little sense to me. 8( Regards, Nightasy
-
Thank you very much for your advice. I set it up as you suggested to check for the number of rows returned and then added in an if-else clause that compared it against a greater then zero. Works like a charm now.
-
Ah, that makes perfect sense. So naturally the if statement is always going to be true because the query is always going to return data whether the data is empty or not, which is why it is always telling me the user already exists. Am I understanding that right?
-
Heya everyone, Still working on learning PHP in my college course and I ran into another problem. I'm kind of stumped because the assignment gave me some extra code, told me exactly where to place it and it is not working. It's kind of frustrating lol. Anyhow, perhaps someone could explain why this is not working. This is the code they told me to put into my script. Instructions: Add the following code to check to see if the guest already exists in the database. Place the code immediately above the INSERT query as part of your validation routines. //Check to see if guest already exists in the database $query = "SELECT * from guests WHERE fname='$fname' AND lname='$lname' AND email='$email'"; if ($result = mysqli_query($connect,$query) or die(mysqli_error($connect))) { echo "You have already signed my guestbook. Thanks!"; } else { YOUR EXISTING INSERT QUERY AND ECHO STATEMENTS DISPLAYING THE QUERY RESULTS ARE HERE } So I did that and here is what it looks like: <?php //Set variable for page title prior to loading header which needs the page title variable. $pagetitle = 'Student, PHP'; //Add in header. include ('includes/header.php'); //Requires the database connection script. require ('includes/connect.php'); ?> <!-- Sticky form displays --> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <fieldset> <legend>Please sign my guest book!</legend> <label for="fname">First: </label><input type="text" name="fname" size="25" maxlength="25" value="<?php if(isset($_POST['fname'])) echo $_POST['fname'];?>"/> <br/> <label for="lname">Last: </label><input type="text" name="lname" size="25" maxlength="25" value="<?php if(isset($_POST['lname'])) echo $_POST['lname'];?>"/> <br/> <label for="email">Email: </label><input type="text" name="email" size="25" maxlength="50" value="<?php if(isset($_POST['email'])) echo $_POST['email'];?>"/> <br/> <label for="password">Password: </label><input type="password" name="password" size="10" maxlength="40" value="<?php if(isset($_POST['password'])) echo $_POST['password'];?>"/> <br/> <label for="confirmpass">Confirm Password: </label><input type="password" name="confirmpass" size="10" maxlength="40" value="<?php if(isset($_POST['confirmpass'])) echo $_POST['confirmpass'];?>"/> <br /> <p><b>Comments</b></p> <textarea name="comment" cols="40" rows="10" maxlength="255"><?php if(isset($_POST['comment'])) echo $_POST['comment'];?></textarea> <br/> <input type="reset" value="Reset"/> <input type="submit" name="submit" value="Submit" /> <br/> </fieldset> </form> <?php //Your PHP code to process the submitted form goes here. if ($_SERVER['REQUEST_METHOD'] == 'POST'){ // Perform Validation if (!empty($_POST['fname'])){ if (!empty($_POST['lname'])){ if (!empty($_POST['email'])){ $email = $_POST['email']; if (strstr($email, '@', true)){ if (!empty($_POST['password'])){ if (!empty($_POST['confirmpass'])){ if ($_POST['password'] == $_POST['confirmpass']){ if (!empty($_POST['comment'])){ $comment = mysqli_real_escape_string($connect, trim($_POST['comment'])); } else if (empty($_POST['comment'])){ $comment = NULL; } // assign and trim variables. $fname = mysqli_real_escape_string($connect, trim($_POST['fname'])); $lname = mysqli_real_escape_string($connect, trim($_POST['lname'])); $email = mysqli_real_escape_string($connect, trim($_POST['email'])); $password = mysqli_real_escape_string($connect, trim($_POST['password'])); // Display connection error if any. if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } //Check to see if guest already exists in the database $query = "SELECT * from guests WHERE fname='$fname' AND lname='$lname' AND email='$email'"; if ($result = mysqli_query($connect,$query) or die(mysqli_error($connect))) { echo "You have already signed my guestbook. Thanks!"; } else { // Enter user input into database $query = "INSERT INTO guests (fname, lname, email, password, comment) VALUES ('$fname','$lname','$email','$password','$comment')"; // If error kill script and display error. if (!mysqli_query($connect,$query)) { die('Error: ' . mysqli_error($connect)); } // Display success messaage. echo "<h1><p class='message'>Greetings $fname</p></h1>"; echo "<p class='message'>Thank you for signing my guest book!</p>"; // Close database connection. mysqli_close($connect); } // If validation fails display. } else if ($_POST['password'] != $_POST['confirmpass']){ echo '<p class="message">Your password confirmation does not match.</p>';} } else { echo '<p class="message">Please confirm your password.</p>';} } else { echo '<p class="message">Please enter a password.</p>';} } else { echo '<p class="message">Please enter a valid email address.</p>';} } else { echo '<p class="message">Please enter an email address.</p>';} } else { echo '<p class="message">Please enter your last name.</p>';} } else { echo '<p class="message">Please enter your first name.</p>';} } //Add in footer. include ('includes/footer.php'); ?> At the far right of my little pyramid scheme here you can see that I put the required code where it asked me to in the instructions. The problem I have now is that I can not longer enter any new users into the database, it always tells me "You have already signed my Guestbook." If anyone can help me out here I would really appreciate it. I just don't understand exactly what the problem is. As always thanks just for looking. Best Regards, Nightasy
-
OMG.... A missing equal sign. I feel really dumb now. I should have seen that cause in this assignment there was a few other little missing symbols here and there. BAH!!!! Thanks so much!
-
Greetings, Working with an assignment in my school I am having an issue getting an Index to validate. Been bashing my head against this all day. I am new to PHP and still learning. <?php /* Students, this script needs 4 files located in the www (Windows) or htdocs (Mac) area in the unit03 subfolder: 1. This file named index.php (this is the core script). 2. The header.html located in the includes subfolder of unit03, which minimally needs to contain HTML document structure tags up to and including the opening body tag. 3. The footer.html located in the includes subfolder of unit03, which minimally needs to contain closing body and html tags. 4. The styles.css located in the includes subfolder of unit03. This project is buggy and your task is to debug it. */ //Set the value of the page title $pagetitle = 'John Doe, IT250 Unit 3'; //Include HTML document structure tags in the header include('includes/header.php'); ?> <!-- Form elements have pre-defined styles in the related CSS. --> <form action="index.php" method="post" name="greeting"> <input type="hidden" name="hour" id="hour" value="" /> <input type="hidden" name="minute" value="" /> <fieldset> <legend>Enter Your Name</legend> <label for="fname">First</label><input type="text" name="fname" size="10"/> <label for="lname">Last</label><input type="text" name"lname" size="10" /> <input type="reset" value="Reset"/> <input type="submit" value="Submit"/> </fieldset> </form> <!-- Gets the user's time and passes it to the hidden input in the form above. Used to customize the greeting. Note the script must be after the form in order to pass the value to the form --> <script type="text/javascript"> var d = new Date(); var h = d.getHours(); var m = d.getMinutes(); document.greeting.hour.value = h; document.greeting.minute.value = m; </script> <?php /*Check if the form was submitted. The following code block will execute upon click of the submit button, otherwise it will just show the form.*/ if ($_SERVER['REQUEST_METHOD'] == 'POST') { // This line of code contained a syntax error $Server should be $_SERVER. //Validate data was entered if (!empty($_POST['fname']) && !empty($_POST['lname'])) { //If data is validated, initialize the text variables and convert them to proper nouns $fname = ucfirst(strtolower($_POST['fname'])); // Here I added a missing ) because it needed the ) to close the statement. $lname = ucfirst(strtolower($_POST['lname'])); // The index was incorrect here so I fixed the name. $hour = $_POST['hour']; $minute = $_POST['minute']; //Decide if it is morning, afternoon, or evening if ($hour < 12) { // This line had a closing semi colon which ended the entire else if arguments. $timeofday = "morning"; } else if ($hour < 18) { // This code was using a ( instead of an opening {. $timeofday = 'afternoon'; } else if ($hour < 24) { $timeofday = 'evening'; } echo '<p class="message">Good ' . $timeofday . " " . $fname . " " . $lname . '!</p>'; // $Fname was incorrectly spelled with a capital F. echo '<p class="message">It is ' . $hour . ':' . $minute . ' your time</p>'; echo '<a href="index.php">Start Over</a>'; } else { //Message to display if data doesn't validate echo '<p class="message">Please enter your name.</p>'; } } // This if else structure was missing a closing bracket. //Include HTML document structure tags in the footer include('includes/footer.php'); ?> I fixed quite a few errors already but I can't for the life of me figure out why the lname index is not validating. Any help or suggestions are much appreciated. Best Regards, Nightasy
-
syntax error, unexpected 'REQUEST_METHOD' (T_STRING)
Nightasy replied to Nightasy's topic in PHP Coding Help
@davidannis - Yea the primary issue was the one that mac_gyver pointed out. I had a feeling the if else statements were going to be wrong. Getting past that error I was able to finish the project in no time flat. So sad that I spent nearly half my morning wrecking my brain over a single quotation mark. -
syntax error, unexpected 'REQUEST_METHOD' (T_STRING)
Nightasy replied to Nightasy's topic in PHP Coding Help
@davidannis - Thanks for that. I sure did miss that one. @mac_gyver - Thank you very much. I see that I missed that ' in the include command. Colors all changed up in my IDE now. Unfortunately I got another error now but I am one step further. I'll fool around with this now on my own and see what I can do. Thanks very much for the help. -
Greetings, I am new to PHP coding and am currently enrolled in a course at my college that is, well, in my opinion poorly designed. Unfortunately I am stuck with the course so I have to do the best I can with what material they have provided. Working on my second assignment for the course I am having a bit of a problem. This is a very basic script with just enough in it that it should run but I get an error when attempting to test it out. Parse error: syntax error, unexpected 'REQUEST_METHOD' (T_STRING) on line 17 //Initialize pagetitle and include header file $pagetitle = 'David Wilson, IT250 Unit 2'; include('includes/header.php); ?> <form action="unit02.php" method="post"> <fieldset> <label for="gasprice">Gas Price</label> <input type="text" name="gasprice"/> <input type="reset" value="Reset"/> <input type="submit" value="Submit"/> </fieldset> </form> <?php //Check if the form was submitted if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (isset($_POST['gasprice'] && is_numeric($_POST['gasprice']) { $gasprice = $_POST['gasprice']; echo $_POST['gasprice']; } else { echo 'wtf'; } //Include footer file include('includes/footer.php'); ?> The other two pages are as follows. header.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title><?php echo $pagetitle; ?></title> <link rel="stylesheet" href="includes/styles.css" type="text/css" /> </head> <body> footer.php </body> </html> Any help would be appreciated. As I stated before, this is a very simple draft of the actual assignment. I just wanted it to at least allow me to see my form so I can tweak it. Unfortunately I can't even get the form to load. Best Regards, Nightasy
-
Fixed my own problem. Syntax error on my part. $premium_query = mysql_query("SELECT 'premium' FROM 'members' WHERE 'username'='".$_SESSION['username']."'"); needed to be $premium_query = mysql_query("SELECT premium FROM members WHERE username='".$_SESSION['username']."'") or die(mysql_error()); Thanks anywho.
-
Before anyone brings this up. There is an extra } on the end of the premium page. I don't know why it didn't paste in the code. But it's there. Sad thing here is I had this same exact script working yesterday and now it doesn't want to play nice. No clue why, I didn't make any changes.
-
I have a login page and at the top of my members page I have another script that checks first if the user is logged in and then checks if the user is premium. Both need to be true for the user to see the members page but instead it keeps going to the activate page when logged in as a premium member. login page <? ob_start();session_start();include_once"config.php"; if(isset($_SESSION['username']) || isset($_SESSION['password'])){ header("Location: videos_main.php"); }else{ if(isset($_POST['login'])){ $username= trim($_POST['username']); $password = trim($_POST['password']); if($username == NULL OR $password == NULL){ $final_report.="Please complete all the fields below.."; }else{ $check_user_data = mysql_query("SELECT * FROM `members` WHERE `username` = '$username'") or die(mysql_error()); if(mysql_num_rows($check_user_data) == 0){ $final_report.="This username does not exist.."; }else{ $get_user_data = mysql_fetch_array($check_user_data); if($get_user_data['password'] != $password){ $final_report.="Your password is incorrect!"; }else{ $start_idsess = $_SESSION['username'] = "".$get_user_data['username'].""; $start_passsess = $_SESSION['password'] = "".$get_user_data['password'].""; $final_report.="You are about to be logged in, please wait a few moments.. <meta http-equiv='Refresh' content='2; URL=videos_main.php'/>"; }}}}} ?> Page with videos on it (Premium) page. <? ob_start(); session_start();include_once"config.php"; if(!isset($_SESSION['username']) || !isset($_SESSION['password'])){ header("Location: login.php"); }else{ $premium_query = mysql_query("SELECT 'premium' FROM 'members' WHERE 'username'='".$_SESSION['username']."'"); $premium = mysql_result($premium_query, 0, 'premium'); if($premium == 0){ header("Location: activate.php"); }else{ $user_data = "".$_SESSION['username'].""; $fetch_users_data = mysql_fetch_object(mysql_query("SELECT * FROM `members` WHERE `username`='".$user_data."'")); } ?> ...//Premium content It's supposed to just show the page content if the $premium returns a value of 1. But it just keeps shooting me to the activate page. Premium is an INT in the database and it defaults to 0 when the user registers, then is changed to 1 when the user activates the account for premium membership. Any ideas?
-
It's funny you made that reply and I thank you soo much for it. I had actually scrapped this method and wound up using a different one that worked but when I tried to update that value it was failing. I was just about to ask about that same thing and here you've already answered the question. Thanks soo much man, saved me a lot of time and now I'm almost ready to launch.