PHP - Checking To See If Value Exists In Variable
If I do a mysql query from a database on a field that either has a number or is blank, how can I write php to check that.
In other words, I am getting that value back into a variable called $isaresult and doing... Code: [Select] if ($isaresult !== '') { //value exists } else { //no value yet } It's that first line of code that doesn't seem to be working. Should I be using "null" or something instead? I'm not real experienced with checking if a value exists, so let me know the proper way to do it (since I assume there are multiple ways). Thanks! Similar TutorialsHi folks, Working on something and I'm not sure how best to do it. It's a system whereby customers can login and see pdf files. Each customer has a unique reference number which is mirrored with a folder on the server, the folder name being the customer reference number. That's the first bit of checking. Then, within that customer folder there will be between 1 and X sub folders which are labelled by unique product reference numbers. Beyond that, each of the product reference folders will have a year folder with a folder for each month of the year going forward. Here's an example of the folder structu - Customer Number (e.g. 12345678) - Product Number (e.g. 456789) (could be more than one) - Year (e.g. 2011) (could be more than one) -Month (e.g. 01/02/03/04/05/06 etc) Essentially, I'm just unsure how to check if folders exist and display their contents if they do. Here's my code so far, which does the first part of checking to see if the product numbers exist, but not the folder checking (I've not activated the hyperlinks in this code yet). This doesn't go as far as years and months yet, just the product number: Code: [Select] $query = mysql_query("SELECT * FROM customers where id = '$id'"); while($rst = mysql_fetch_array($query)) { echo "$rst[company_name]"; } $query = mysql_query("SELECT * FROM sites where company_name = '$company'"); while($rst = mysql_fetch_array($query)) { echo "$rst[site]<br>"; if ($rst[product1] !== ""){ echo "- <a href='#'>$rst[product1]</a><br>"; } if ($rst[product1] == ""){ echo ""; } if ($rst[product2] !== ""){ echo "- <a href='#'>$rst[product2]</a><br>"; } if ($rst[product2] == ""){ echo ""; } if ($rst[product3] !== ""){ echo "- <a href='#'>$rst[product3]</a><br>"; } if ($rst[product3] == ""){ echo ""; } if ($rst[product4] !== ""){ echo "- <a href='#'>$rst[product4]</a><br>"; } if ($rst[product4] == ""){ echo ""; } if ($rst[product5] !== ""){ echo "- <a href='#'>$rst[product5]</a><br>"; } if ($rst[product5] == ""){ echo ""; } How can I check to see if a webpage exists with PHP. for example http://www.google.com/ would be true and http://fakeurl32939232.com/filepage.html = false What function/syntax would I have to use? Hi Guys, I'm using the following code to write emails to a .txt file: // Write the email to file $leadsFile = "leads/emails.txt"; $fh = fopen($leadsFile, 'a') or die ("can't open leads file!"); $writeData = "$conEM\r\n"; fwrite($fh, $writeData); fclose($fh); which works great, but i can't figure out how to NOT write an email to the .txt file if it's already on it, i'm not using a database for a change i'm stumped lol thanks for any help guys Graham Hi, Im trying to generate a random 4- digit code, and then check if it is allready in the database. My current code is below, but im not sure how to make it loop again, if the code exists. Also, im not sure if this is the best way of doing this, maybe someone could suggest something better... This is basicly what im trying to do: 1. hash the code 2. check if it exits in the DB 3. if it does, re-generate, and repeat 2., if not, return it function getUniqueHash() { global $mysql_server, $mysql_user, $mysql_password; $code = substr(md5(uniqid(rand(), true)), 0, 4); mysql_connect($mysql_server, $mysql_user, $mysql_password); // connect // $sql = "SELECT * FROM `$mysql_db`.`short` WHERE `short` = '$code'"; $result = mysql_query($sql); $results = mysql_numrows($result); if($results > 0) { //GO BACK AND RE-GENERATE CODE AND REPEAT CHECK } else { return $code; } mysql_close(); } PasteBin: Quote http://paste.tgxn.net/?s=9 This is something that has intrigued me, that has only recently surfaced when viewing the forum. Which of the following methods of authenticating that a user exists would be better/faster/ect? Example 1 - Fetching Row Data <?PHP $username = 'LoserVille'; $password = 'password'; $myQuery = mysql_query("SELECT account_id FROM user_accounts WHERE username = '$username' AND password = '$password'"); $myQuery = mysql_fetch_assoc($myQuery); if($myQuery) { /*### User Exists ###*/ } else { /*### User Does Not Exist ###*/ } ?> Example 2 - Fetching Number of Results <?PHP $username = 'LoserVille'; $password = 'password'; $myQuery = mysql_query("SELECT account_id FROM user_accounts WHERE username = '$username' AND password = '$password'"); $myQuery = mysql_num_rows($myQuery); if($myQuery >= 1) { /*### User Exists ###*/ } else { /*### User Does Not Exist ###*/ } ?> Just looking for some insight, not really a problem Regards, PaulRyan. I have come across couple of similar answers for my question in this form, but could not solve my exact problem. Therefore I am posting this he I have an xml file as shown below: <?xml version="1.0" encoding="ISO-8859-1"?> <document> <user> <user_id>0121</user_id> <name>Tim</name> <file>0121.file</file> </user> <user> <user_id>0178</user_id> <name>Henry</name> <file>0178.file</file> </user> <user> <user_id>0786</user_id> <name>Martin</name> <file>0786.file</file> </user> <user> <user_id>1239</user_id> <name>Jan</name> <file>1239.file</file> </user> </document> I ask the user to input his user_id and post this user_id and perform a check on the entire xml file to check whether the entered user_id exists in the xml file or not. If exists then I go further if not echo a error message. Can anybody pull me out of this? Thanks Hi, I'm making a website that uses data stored in SQL. One of my pages allows the user to enter a new product into a product table. I was wondering if somebody could help me with some validation or Query that will not allow the user to enter a product name that already exists in the table? Code: [Select] $nameNew = $_POST['new]; $nameID = $_POST['newID]; $namePrice = $_POST['newPrice]; INSERT INTO products VALUES ($nameNew, $newID, $newPrice) $describeQuery = "SELECT ID, Name, Price FROM Products"; $results = sqlsrv_query($conn, $describeQuery); echo '<table border="1" BORDERCOLOR=Black>'; echo '<tr><th bgcolor = "LightBlue">Name</th><th bgcolor = "LightBlue" >ID</th> <th bgcolor = "LightBlue" >Price</th></tr>'; while($row = sqlsrv_fetch_array($results, SQLSRV_FETCH_ASSOC)) { echo '<tr>'; echo '<td >' .$row['Name'].'</td>'; echo '<td>' .$row['ID'].'</td>'; echo '<td>' .$row['Price'].'</td>'; echo '</tr>'; } echo '</table>'; sqlsrv_close($conn); Thanks How can I check a variable to see if it is NULL and if so set to 0000-00-00? I've tried: if ($var IS NULL) THEN $var='0000-00-00'; to no avail. Hi Guyz, I need to check the variable $itemDescription to see if the client has entered a '1' before the item description(example: 1 table) Reason, is the client would like to add sales tax to all NOn-Food related items of 6.25% This is for a local auction house. It needs to be simple. i,e. Don't wanna add any more form fields. Just let the user type the number 1 before all items that need to be taxed. Here's my code: Code: [Select] <?php ob_start(); ?> <link rel="stylesheet" href="style.css" type="text/css"> <style type="text/css"> </style> </head> <?PHP session_start(); ob_start(); # Config settings below # Change these to whatever you want :) ############################# $cellsPerRow = '6'; ############################# include('connect.php'); // These queries get the amount of bidders that are in the database $getAllBidders = mysql_query("SELECT `id` FROM bidders"); $totalBidders = mysql_num_rows($getAllBidders); // This section is to check if the Add New Item form has been submitted if($_POST['addNewItem']) { // Retrieve Query Strings from URL $itemDescription = $_POST['itemDescription']; $itemPrice = $_POST['itemPrice']; $winningBidder = $_POST['winningBidder']; $totalDeals = $_POST['totalDeals']; $totalPrice = ($totalDeals*$itemPrice); // Check the submitted data and make sure all is correct if(!$itemDescription) { $message = 'You must enter an Item Description.'; } else if(!$itemPrice) { $message = 'You must enter an Item Price.'; } else if(!$winningBidder) { $message = 'You must enter a Winning Bidder ID.'; } else if(!$totalDeals) { $message = 'You must enter the amount of Deals.'; } else if(!is_numeric($winningBidder)) { $message = 'The Winning Bidder ID can only be numbers.'; } else { // Check to see if the bidder ID already exists $checkBidder = mysql_query("SELECT * FROM bidders WHERE biddersId='$winningBidder' LIMIT 1"); $checkBidder = mysql_fetch_assoc($checkBidder); // If the Bidder ID does not exist, we re-direct to allow us to save the Bidder ID if(!$checkBidder) { header("Location: ?action=confirmListing&iDesc=".$itemDescription."&iPrice=".$itemPrice."&wBidder=".$winningBidder."&tDeals=".$totalDeals.""); } else { // If Bidder ID exists we just insert the transaction accordingly mysql_query("INSERT INTO transactions (`itemDescription`, `itemPrice`, `bidderId`, `itemQty`, `totalPrice`) VALUES ('$itemDescription', '$itemPrice', '$winningBidder', '$totalDeals', '$totalPrice');"); $message1 = 'The transaction has been successfully added.'; mysql_query("SELECT owed From bidders WHERE biddersId='$winningBidder'") or die(mysql_error()); if ($row['owed']==0) { mysql_query("UPDATE bidders SET owed='1' WHERE biddersId='$winningBidder'") or die(mysql_error()); } } } } // This section is to check if the Add Bidder to database form has been submitted if($_POST['confirmBidder']) { $itemDescription = $_POST['itemDescription']; $itemPrice = $_POST['itemPrice']; $winningBidder = $_POST['winningBidder']; $totalDeals = $_POST['totalDeals']; $totalPrice = ($itemPrice*$totalDeals); $addBidder = $_POST['addBidder']; $checkInput= preg_match([1]+*); if ($itemDescription== $checkInput) $itemPrice= $itemPrice * 6.25%; mysql_query("INSERT INTO transactions (`itemDescription`, `itemPrice`, `bidderId`, `itemQty`, `totalPrice`) VALUES ('$itemDescription', '$itemPrice', '$winningBidder', '$totalDeals', '$totalPrice');"); $message1 = 'The transaction has been successfully added.'; if($addBidder == 'Yes') { mysql_query("INSERT INTO bidders (biddersId) VALUES ('$winningBidder');"); $message1 .= '<br> The Bidder ID has also been added.'; mysql_query("SELECT owed From bidders WHERE biddersId='$winningBidder'") or die(mysql_error()); if ($row['owed']==0) { mysql_query("UPDATE bidders SET owed='1' WHERE biddersId='$winningBidder'") or die(mysql_error()); } } if($addBidder == 'No') { $message1 = '<br><font color= "red"> Bidder has NOT been logged.</font>'; } // $itemDescription = ''; // $itemPrice = ''; // $winningBidder = ''; // $totalDeals = ''; // $totalPrice = ''; // $addBidder = ''; } ?> <?PHP // This line of code will check the current task we are doing if($_GET['action'] == 'confirmListing') { $itemDescription = $_GET['iDesc']; $itemPrice = $_GET['iPrice']; $winningBidder = $_GET['wBidder']; $totalDeals = $_GET['tDeals']; ?> <form name="confirmBidder" method="POST" action="?"> <?PHP // This is the hidden data from the previous form // Better than using sessions and GET query ?> <input type="hidden" name="itemDescription" id="itemDescription" value="<?PHP echo $itemDescription;?>"> <input type="hidden" name="itemPrice" id="itemPrice" value="<?PHP echo $itemPrice;?>"> <input type="hidden" name="winningBidder" id="winningBidder" value="<?PHP echo $winningBidder;?>"> <input type="hidden" name="totalDeals" id="totalDeals" value="1"> <table cellpadding="0" cellspacing="1" border="0" style="background: #ffffff; margin: auto;"> <tr> <td colspan="2" class="formHeader"> Add New Auction Item </td> </tr> <tr> <td class="formField"> Add This Bidder? </td> <td class="formValue"> <select name="addBidder" id="addBidder" class="input" style="width: 195px;"> <option value="Yes">Yes</option> <option value="No">No</option></select> </td> </tr> <tr> <td colspan="2" class="formButton"> <input type="submit" name="confirmBidder" id="confirmBidder" value="Confirm Bidder Action?"> <input type="reset" name="reset" id="reset" value="Reset Form"> </td> </tr> </table> </form> <?PHP // If the action is not to confirm a listing then show add item section } else { ?> <?PHP//----- Add New Item Section -----\\?> <?PHP if($message) { echo '<div class="Error">',$message,'</div><div style="height: 10px;"></div>'; } else if($message1) { echo '<div class="Success">',$message1,'</div><div style="height: 10px;"></div>'; } ?> <form name="addNewItem" method="POST" action="?"> <table cellpadding="0" cellspacing="1" border="0" style="background: #ffffff; margin: auto;"> <tr> <td colspan="2" class="formHeader"> Add New Auction Item </td> </tr> <tr> <td class="formField"> Item Description </td> <td class="formValue"> <input type="text" name="itemDescription" class="formText" id="itemDescription" value="<?=$itemDescription;?>" style="width: 195px;"> </td> </tr> <tr> <td class="formField"> Item Price </td> <td class="formValue"> <input type="text" name="itemPrice" class="formText" id="itemPrice" value="<?=$itemPrice;?>" style="width: 195px;"> </td> </tr> <tr> <td class="formField"> Winning Bidder ID </td> <td class="formValue"> <input type="text" name="winningBidder" class="formText" id="winningBidder" style="width: 195px;"> </td> </tr> <tr> <td class="formField"> How Many Deals? </td> <td class="formValue"> <input type="text" name="totalDeals" class="formText" id="totalDeals" value="1" style="width: 195px;"> </td> </tr> <tr> <td colspan="2" class="formButton"> <input type="submit" name="addNewItem" id="addNewItem" value="Add New Auction Item?"> <input type="reset" name="reset" id="reset" value="Reset Form"> </td> </tr> </table> </form> <?PHP//----- Add New Item Section -----\\?> <?PHP } ?> All help appreciated to the fullest... Code: [Select] <?php function Login() { session_start(); $_SESSION["loggedin"] = true; echo "You are logged in!"; header("Location: ../L_index.php"); //Aka Logged in Index. } function Logout() { $_SESSION["loggedin"] = false; session_destroy(); } function checklogin() { session_start(); if ($_SESSION["loggedin"] == true) { return true; } else { return false; } } ?> This is just a tiny bit of my code, there is security holes, but as you see, there is 3 functions: Login Logout Checklogin But when i use the Login function, everything is fine, but if i then use the checklogin, then it always returns true(it returns true after i used the logout function), why? Hi All, I'm having a major mind blank, and can't find anything in the previous posts resolving what I'm after. I'm setting $searchtext = $_POST['searchtext']; I want to check $seachtext is not null. I've seen isset($searchtext) but it doesn't solve my problem. Basiclaly; I want an if statement to say if(isset($searchtext)) {......} Thoughts? I have the following if statement: Code: [Select] if ((isset($select_category) == 'All') || (!isset($select_category)) && (!isset($most_liked))) { The value for the variable gets taken from a drop down menu, which is a list of categories. The problem I am having is with the isset condition check is that the variable is always set, but it does not consider the check for equality with the 'All' condition. Which basically means no matter which category I choose from the drop down menu, it always goes to this very first if statement, and does NOT go to the other elseif statement, and I think it has to do with the isset condition check, because without it it would work, though without it I am getting a notice warning, that the variables are undefined. Any ideas how I can make it check if its equal to 'All' together with the isset condition check? What I am trying to say is no matter which category is chosen, with the isset condition check, the variable is always set, thus the if statement is true, there basically seems to be a contradiction going on. Hi community,i creating a simple website and description i analyzed my code about 3days...2hours a day. if i get the point in my head.then its say Website url is in use..but not..ok maybe i give the code below. so if you can explain whats wrong.thanks Code: [Select] <?php include_once ('connect.php'); $url= mysql_real_escape_string($_POST['url']); $desc=mysql_real_escape_string($_POST['desc']); if ($id == "krauti") { if (empty($_POST['url']) && empty($_POST['desc'])) { die('<br><center>Both Empty!.<center/><br/>'); } if (empty($_POST['url'])) { die('<br><center>URL Empty!.<center/>'); } if (empty($_POST['desc'])) { die('<br><center>desc empty fill it!.<center/>'); } $url = htmlspecialchars( stripslashes( strip_tags($_POST['url'] ) ) ); $aprasymas = htmlspecialchars( trim($_POST['desc'] ) ); $query = mysql_query("SELECT * FROM linkai WHERE url = '$url' AND 'desc' = '$desc'"); if( mysql_num_rows( $query ) == 1 ) { "INSERT INTO linkai ". "(id, url, desc) ". "VALUES('','$_POST[url]','$_POST[desc]')"; echo "Yes!."; } else if (mysql_num_rows($query) == 0 ){ echo "No!!"; } } ?> Can someone explain why this code: if (mysql_result($data,0,$SQLLargeName) = " "){ $LargeImage = "#"; } else { $LargeImage = mysql_result($data,0,$SQLLargeName); } Gives me this error? Fatal error: Can't use function return value in write context in /home/worldw44/public_html/SQL.php on line 38 And ways round it? Thanks. <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function popUp(URL,URL2) { day = new Date(); id = day.getTime(); eval("page" + id + " = window.open(URL,'" + id + "', 'toolbar=0,scrollbars=1,location=0,top=10,left=10,statusbar=0,menubar=0,resizable=0,width=408,height=400');"); day = new Date(); id = day.getTime(); eval("page" + id + " = window.open(URL2,'" + id + "', 'toolbar=0,scrollbars=1,location=0,top=10,left=450,statusbar=0,menubar=0,resizable=0,width=408,height=400');"); } // End --> </script>I have a map which shows sales people by location and if more then one sales person exists then I would need 2 pop up windows. This works great other than the fact that the areas with one sales person are getting a blank 2nd popup as a second salesperson does not exist. Any help would be appreciated. Thanks In Advance Edited by phpbeginner, 27 June 2014 - 05:52 AM. Maybe I am over thinking this, but I would like to see if their is another value after the current value without moving the internal array pointer. What can I do? Hi all, I have the following mysql delete query that essentially deletes a row from two seperate tables "messages" and "messages2" where the id is equal to that in both of the tables. The problem I am getting (for obvious reasons) is that it will only delete from the table, if it indeed exists in both tables. Here is the query: Code: [Select] DELETE FROM messages,messages2 USING messages,messages2 WHERE messages.id = messages2.id AND messages.id = ?; How would I go about setting it so that the query always deletes from table "messages" and only deletes from "messages2" when a corresponding id exists? I think it would involve an IF EXISTS clause, but I am not sure on this, or indeed how to implement it. Thanks in advance guys Dan My error below returns (echos) that there is no data under the table sites to display. But, there is. Why is it doing this? class_l.php <?php class displaySites { function grabSites() { $query = mysql_query("SELECT title,description,votes,dates,comments,out,in FROM sites ORDER BY id DESC LIMIT 100"); if(mysql_num_rows($query) > 0) { while($fetch = mysql_fetch_assoc($query)) { echo " <div id='post-1' class='post'> <h2 class='title'><a href='#'>". $fetch['title'] ."</a></h2> <h3 class='date'>Submitted on ". $fetch['date'] ."</h3> <div class='entry'> <p>". nl2br(stripslashes($fetch['description'])) ."</p> </div> <p class='meta'><a href='#'>View</a></p> <div class='hr'> </div> </div> "; } } else { echo " <div id='post-1' class='post'> <h2 class='title'><a href='#'>Oh NOEZ!</a></h2> <h3 class='date'>". date("M-d-Y") ."</h3> <div class='entry'> <p>There are currently no sites to display!</p> </div> <p class='meta'>View</p> <div class='hr'> <hr /> </div> </div> "; } } } class register { function createAccount() { $username = mysql_real_escape_string($_POST['username']); $password = md5(sha1(sha1($_POST['password']))); $name = mysql_real_escape_string($_POST['title']); $description = mysql_real_escape_string($_POST['description']); if(isset($username) && isset($password) && isset($name) && isset($description)) { if(!$username || !$password || !$name || !$description) { echo '<table border="0"><form action="register.php" method="POST"> <tr><td>Username</td><td><input type="text" name="username" maxlength="20"></td></tr> <tr><td>Password</td><td><input type="text" name="password" maxlength="30"></td></tr> <tr><td>Site Name</td><td><input type="text" name="title" maxlength="25"></td></tr> <tr><td>Site Description</td><td><textarea cols="40" rows="18" name="description" maxlength="750"></textarea></td></tr> <tr><td>Finish!</td><td><input type="submit"></td></tr> </form></table>'; } else { $query = mysql_query("SELECT * FROM sites WHERE username = '$username' LIMIT 1"); if(mysql_num_rows($query) > 0) { echo "Sorry, an account with this username already exists."; } else { $date = date("M-d-Y"); $ip = $_SERVER['REMOTE_ADDR']; //create their account mysql_query("INSERT INTO sites VALUES (null, '$username', '$password', '$name', '$description', 0, 0, 0, '$date', '$ip', 0)"); echo "You have successfully registered your site on NovaTops! <a href='login.php'>Login</a>"; } } } else { echo "One or more of the variables are not set."; } } } class login { function verifyLogin() { $username = mysql_real_escape_string($_POST['username']); $password = md5(sha1(sha1($_POST['password']))); if(isset($username) && isset($password)) { if(!$username || !$password) { echo "<table><form action='login.php' method='POST'> <tr><td>Username</td><td><input type='text' name='username' maxlength='20'></td></tr> <tr><td>Password</td><td><input type='password' name='password' maxlength='30'></td></tr> <tr><td>Finished?</td><td><input type='submit'></td></tr> </form></table>"; } else { $query = mysql_query("SELECT * FROM sites WHERE username = '$username' AND password = '$password'LIMIT 1"); if(mysql_num_rows($query) > 0) { echo "Congratulations! You have successfully logged in! <a href='index.php'>Home</a>"; $_SESSION['user'] = $username; } else { echo "It seems you've typed in the wrong username and/or password. <a href='login.php'>Try Again</a>"; } } } else { echo "One or more of the variables aren't set."; } } } ?> index.php <?php include_once('includes/config.php'); include_once('class_l.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title><?php echo $title; ?></title> <meta name="keywords" content="" /> <meta name="description" content="" /> <link href="styles.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="wrapper"> <div class="top_text"><h1><a href="#"><?php echo $site_name; ?></a></h1> <h2><a href="#"><?php echo $slogan; ?></a></h2></div> <div id="content"> <div id="blog"> <div id="post-1" class="post"> <h2 class="title"><a href="#">Welcome to NovaTops!</a></h2> <h3 class="date">Created on April 06, 2011</h3> <div class="entry"> <p>Hello there! If your viewing this message right now, your on the awesome site called NovaTops! NovaTops allows you to register your site in our database, and then the site's script automatically starts to rank your site. The higher your rank, the more likely your site's going to get a ton of views!</p> </div> <div class="hr"> <hr /> </div> </div> <!-- end #post-1 --> <?php $displaySites = new displaySites(); $displaySites->grabSites(); ?> </div> <!-- end #blog --> <?php include_once('includes/navigation.php'); ?> <!-- end #sidebar --> <div style="clear: both; height: 1px;"></div> </div> <!-- end #content --> <div id="footer"> <p>Copyright © 2011. Design by <a href="http://www.flashtemplatesdesign.com/" title="Free Flash Templates">Free Flash Templates</a></p> <p><a href="#">Privacy Policy</a> | <a href="#">Terms of Use</a> | <a href="http://validator.w3.org/check/referer" title="This page validates as XHTML 1.0 Transitional"><abbr title="eXtensible HyperText Markup Language">XHTML</abbr></a> | <a href="http://jigsaw.w3.org/css-validator/check/referer" title="This page validates as CSS"><abbr title="Cascading Style Sheets">CSS</abbr></a></p> </div> </div> <!-- end #wrapper --> </body> </html> Hi, I have a sign up form that generates a activation key and emails it to user and they cannot login until account has been activated etc. My problem is i am not sure how to in php generate a new activation key if the generated one has already been used. I know how to do the MySQL query to check if activation key already exists but not sure how to basically tell PHP that if the activation key already exists in DB then generate a new key until one is found that does not already exist. I gather i may need a loop but not sure. Could someone please help ? Like i say i know how to do the MySQL query just need some sample code to know how to do what i asked above. Thanks for anyhelp; Much Appreciated I apologize in advance for any misuse of terminology. I find that I am rather ignorant in such things. I'm working on a WordPress theme. Specifically on the part that shows the "next: link-to-next-post" and "previous: link-to-prev-post" links. Here is the code that I have: Code: [Select] <?php $nextvar=next_post_link('%link'); $prevvar=previous_post_link('%link'); ?> <?php if (isset($nextvar)) { ?> <h3>Next</h3> <p><?php next_post_link('%link'); ?></p> <? } ?> <?php if (isset($prevvar)) { ?> <h3>Previous</h3> <p><?php previous_post_link('%link'); ?></p> <? } ?> The first part intends to check if the links exist. And this works fine. However, the only output I'm getting are the values of $nextvar and $prevvar. The headers are nonexistent. What's wrong? Any help is much appreciated, and I thank you in advance. |