PHP - Need Help Negating Statement
I want to negate the following statement so I can flip my THEN and ELSE...
// Check # of Records Returned. if (mysqli_stmt_num_rows($stmt2)==1){ // Member was Found. }else{ // Member Not Found. $errors['currPass'] = 'The E-mail and Password do not match those on file.'; } Would this do the exact same thing... // Check # of Records Returned. if (mysqli_stmt_num_rows($stmt2)!==1){ // Member Not Found. $errors['currPass'] = 'The E-mail and Password do not match those on file.'; }else{ // Member was Found. } Debbie Similar TutorialsIf I want to negate this... Code: [Select] if (preg_match()) Would this work... Quote if (!preg_match()) Debbie I want to negate this line of code... Code: [Select] if (is_null($activationCode)){ Is this the proper way to do it... Quote if (!is_null($activationCode)){ Thanks, Debbie I'm having issues with the following: Code: [Select] <?php session_start(); $_SESSION['username']=$_POST['username']; $_SESSION['password']=$_POST['password']; if($_SESSION['username']=="username" && $_SESSION['password']=="password"){ if($_GET['product']=="add"){ $content.=' <p><label>Product Name:</label> <input type="text" name="product_name" size="30" /> <label>Product Price:</label> <input type="text" name="product_price" size="5" /> </p> <p><label>Product Category:</label> <input type="text" name="product_category" size="30" /></p> <p><label>Product Link:</label> <input type="text" name="product_link" size="30" /></p> <p><label>Product Image:</label> <input type="text" name="product_image" size="30" /></p> <p><label>Product Tag:</label> <input type="text" name="product_tag" size="30" /></p> <p><label>Product Keywords:</label> <input type="text" name="keyword" size="30" /></p> <p><label>Product Features:</label><br /> <textarea name="product_features" rows="10" cols="60"></textarea> </p> <p><label>Product Pros:</label><br /> <textarea name="product_pros" rows="5" cols="30"></textarea> </p> <p><label>Product Cons:</label><br /> <textarea name="product_cons" rows="5" cols="30"></textarea> </p> <p><label>Product Description:</label><br /> <textarea name="product_description" rows="10" cols="60"></textarea> </p> <p><label>Product Notes:</label><br /> <textarea name="product_notes" rows="5" cols="30"></textarea> </p> '; $logout='<div><a href="./acp_admincp.php?log-out">Log-Out</a></div>'; } elseif($_GET['product']=="view"){ } else{ $content.=' <a href="./admincp.php?product=add">Add New Product</a> <br /> <a href="./admincp.php?product=view">View Products</a> '; } } elseif(isset($_GET['log-out'])){ session_start(); session_unset(); session_destroy(); header("Location: ./admincp.php"); } else{ $content=' <form action="./admincp.php" method="post"> <p><label>Username:</label> <input type="text" name="username" size="30" />'; $content.='</p> <p><label>Password:</label> <input type="password" name="password" /></p>'; $content.='<p><input type="submit" value="Submit" name="Submit" /></p> </form>'; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <base href="http://ghosthuntersportal.com/" /> <title>Ghost Hunter's Portal - Admin Control Panel</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="verify-v1" content="" /> <meta name="keywords" content="ghost, hunters, hunter, ghosts, spirit, spirits, paranormal, investigation, investigator, investigators, k2, emf, meter, kii" /> <meta name="description" content="Ghost Hunters Potal. Parnormal research equipment store." /> <meta name="author" content="Andrew McCarrick" /> <meta name="robots" content="index, follow" <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <img src="./logo.png" alt="Ghost Hunter's Portal Admin Control Panel" /> <br /> <div style="color: #AA44AA; font-size: 26px; margin-top: -30px; margin-left: 125px;">Admin Control Panel</div> <?php echo $logout; echo $content; ?> </body> </html> I can log-in, and get to the page with the two links on it. However, once I click one of the links it falls back to the log-in page, and it ends up being a never ending loop. It's doing this: Log-In --> Page with links ---> Log-In page again Should be doing this: Log-In --> Page with links --> Add Product page or View Products page I can never get into the the actual sub page. Just to be clear, the address bar actually shows product=add or product=view, but it still shows the log-in page. Hello Everyone, I have to change the if statements to a switch statement, in this game. Can anyone help? Thanks. var checkKeyPressed = function (e) { // Press key A or key D to make dog run to the left or right // The running speed is specified by the step variable, 10 by default. // If you replace 10 with a larger integer, the dog will run faster. //press A, dog runs left if (e.keyCode == "65") { if (prex[0] > 5) { prex[0] = prex[0] - step; } } //press D, dog runs right if (e.keyCode == "68") { if (prex[0] < right) { prex[0] = prex[0] + step; } } }; I'm just trying something new out here and wanted to know how it looked AND I'm having a hard time figuring out how to accomplish this with the else statement. Obviously on the else it would mean that there was already a template with the same name existing in the database table so I want the user to be sent back to the original form and I'll implement a jquery dialog box telling the user that there is already an existing template with that name. if (isset($_POST['edittemplate'])) { $templatename = mysqli_real_escape_string($dbc, $_POST['templatename']); $headercode = mysqli_real_escape_string($dbc, $_POST['headercode']); $footercode = mysqli_real_escape_string($dbc, $_POST['footercode']); $templateID = (int)$_POST['templateID']; $query = "SELECT * FROM `templates` WHERE `templatename` = $templatename"; $result = mysqli_query ( $dbc, $query ); // Run The Query $rows = mysqli_num_rows($result); if ($rows == 0) { $query = "UPDATE `templates` SET `templatename` = '$templatename', `headercode`='".$headercode."', `footercode`='".$footercode."' WHERE `id` = '$templateID'"; mysqli_query($dbc,$query); } else { } } I have a simple if statment issue. Here is the code <?php $address = $User['address_l1']; if (empty($address)) { echo "You have not entered an address";} else {echo "You Have entered an address";} ?> The variable $address in this case is not empty so it should echo you HAVE entered an address but its echoing NOT. Can somebody please explain why this is not working? Hi there can anybody help me please? my if statement isnt working?? All i am trying to do is display an image if the session variable is == entered varialble "Empire" I get the error message "Parse error: syntax error, unexpected T_VARIABLE, expecting " Code: [Select] if $_SESSION['MM_Username'] == 'Empire'{ echo'<img src="Images/empicon.jpg" width="20" height="20" class="moncalimari"/>' ; } ?> I have checked and the session does == Empire Please help Thank you. i want do do something like this I've never really had this problem before. I'm trying to make it so only moderators can edit titles. This is currently my if statement: elseif($type == 2 && acc_status(getUsername()) > 1 && !isset($_POST['title']) || !isset($_POST['content'])) (I can assure you getUsername() works) Interpretation: If the editing type is 2 (thread/topic) and the user's account status is higher than 2 (meaning admin & mod) and the title or message/content isn't set, display the content within the if statement block. Why is it users with a user status of 1 can see the information within the block statement, allowing them to see the "edit title" field? this if statement isn't working.. $newid is an integer, which is the name of a variable of an array e.g. $53. The below code should check if the array exist. it should echo yes.. instead it is blank. Code: [Select] if(isset(${"$newid"})) { echo "yes"; //code } Hello all, I need your help. I have two pages. This is the 1st page: <?php include "include/dbc.php"; include "include/header.inc"; ?> <style type="text/css"> .mydate{ color:#00F; text-decoration:underline; cursor:pointer; } </style> <script type="text/javascript"> function displayDate(d){ var date=new Date(); var D=date.getDate(); date.setDate(D+d); var YYYY=date.getFullYear(); var MM=date.getMonth()+1; MM<10?MM='0'+MM:null; var DD=date.getDate(); DD<10?DD='0'+DD:null; var span=document.getElementById('date'); span.innerHTML= 'Entries for '+MM+'/'+DD+'/'+YYYY; } onload=function(){displayDate(0)}; </script> <h1>Food Diary</h1> <div class="full"> <center><div><span class="mydate" onclick="displayDate(-1)"><img src="images/left_arrow.png" border="0">Yesterday</span> <span id="date" style="font-size:2em;"></span> <span class="mydate" onclick="displayDate(1)">Tomorrow<img src="images/right_arrow.png" border="0"></span></div><br /> <a href="#" onclick="displayDate(0);return false;">Today</a> </center> <div class="full"> <form name="exercise" id="exercise" method="GET" action=""> <center><table> <tr> <td><h3>Add an Activity</h3></td> </tr> <tr> <td><input name="NewSearchString" style="width: 100px" type="text"/> <input type="submit" value="Search" /> </td> </tr> <tr> <td> <select name="activity"> <option value="_">Activity Browse...</option> <option value="all">All Activities</option> <option value="biking">Biking</option> <option value="condition">Conditioning</option> <option value="dancing">Dancing</option> <option value="fish">Fishing & Hunting</option> <option value="Home">Home Activities</option> <option value="misc">Miscellaneous</option> <option value="music">Music Playing</option> <option value="occupation">Occupation</option> <option value="running">Running</option> <option value="sports">Sports</option> <option value="walking">Walking</option> <option value="water">Water Activities</option> <option value="winter">Winter Activities</option> </select> <input type="submit" value="Submit" /></td></tr></table></center></form> </td> </tr> </table> </center> <table width="100%"> <tr bgcolor="#66CC33"> <td><div>Activity</div></td> <td><div>Specific Activity</div></td> <td><div>Time (hh:mm)</div></td> <td><div>Distance</div></td> <td><div>Units</div></td> </tr> <tr bgcolor="#66CC33"> <td><div></div></td> <td><div></div></td> <td><div></div></td> <td><div class="Float"></div></td> <td class="cp_Distance"><div></div></td> </tr> <?php if(isset($_GET[activity])) { $category=$_GET[activity]; $result = mysql_query("SELECT * FROM exercise WHERE type='$category'"); ?> <form action="add_activity.php" method="POST"> <?php while($row = mysql_fetch_array($result)) { echo '<tr><td><div>'.$row[Type].'</div></td>'; echo '<td><div>'.$row[Name].'<input type="hidden" name="exerciseid[]" value="'.$row[Name].'"></div></td>'; echo '<td><div><input type="text" name="duration['.$row['Name'].']" value=""></div></td>'; echo '<td><div><input type="text" name="distance['.$row['Name'].']" value ""></div></td>'; echo '<td><div><select name="metric[]"> <option value="mile" name="mile">mile</option> <option value="Km" name="Km">km</option> <option value="M" name="M">m</option> <option value="Yard" name="yard">yrd</option> <option value="Feet" name="feet">ft</option> </select></div></td></tr>'; } mysql_close(); ?> <tr><td colspan="6" align="center"><input type="submit" name="submit" value="Add Activities" onClick="return confirm( 'Are you sure you want to submit the activities?');"></td></tr> </form> <?php } ?> <tr bgcolor="#66CC33"> <td><div></div></td> <td><div></div></td> <td><div></div></td> <td><div class="Float"></div></td> <td class="cp_Distance"><div></div></td> </tr></table> This page contains a table that is pulling info from a database stored in phpmyadmin. The values entered in that table are passed to the second page: <?php include "include/dbc.php"; include "include/header.inc"; $exerciseid = $_POST["exerciseid"]; $duration = $_POST["duration"]; $distance = $_POST["distance"]; $metric = $_POST["metric"]; echo'<h1>Added Activities</h1>'; // name of array echo '<h1>Exercise</h1>'; if (is_array($exerciseid)) { foreach ($exerciseid as $key => $value) { echo $key .' : '. $value .'<br />'; } } echo '<h1>Duration</h1>'; if ($duration == ""){ echo "No value"; } // name of array echo '<h1>Distance</h1>'; if (is_array($distance)) { foreach ($distance as $key => $value) { echo $key .' : '. $value .'<br />'; } } // name of array echo '<h1>Metric</h1>'; if (is_array($metric)) { foreach ($metric as $key => $value) { echo $key .' : '. $value .'<br />'; } } ?> The problem is that ALL the values, empty or w/content, are being passed. So I was wondering if there was a way to pass only user input with an if/else statement. Something like: if ($duration == ""){ echo "No value"; else echo duration; } This, however, is not working and I would like to know what possibly could work that would be structured similarly. Thanks in advance. I have a query that outputs certain values in a table, but i want to put a conditional if statement. What i have right now is if the status is 1 echo Close and if the status is 0 Open what i want it to do now is not to show the values that have 1 along with all the other database table entries how would i do that Code: [Select] //if statement for status if($rows['status'] == 1) { $status = "Close"; } else $status = "Open"; ?> Can someone write me some simple code to check to see if the url has the word "soundcloud" in them. This is what I want to do.... This is my code now... Code: [Select] echo " <h3> $title - $author</h3> </br> <iframe width='640' height='360' src='$link' frameborder='0' allowfullscreen></iframe> </br> </br> $message </br> <font color='#8b8d9b' size='1'>Posted By: $username $date</font> </br></br></br></br></br> "; However I want to pull the link value out of the database and see if it contains the word "soundcloud" and if it does do this...(note the height is changed) Code: [Select] echo " <h3> $title - $author</h3> </br> <iframe width='640' height='100' src='$link' frameborder='0' allowfullscreen></iframe> </br> </br> $message </br> <font color='#8b8d9b' size='1'>Posted By: $username $date</font> </br></br></br></br></br> "; Any help would be greatly appreciated. Code: [Select] <?php mysql_connect("localhost","root") or die(mysql_error()); mysql_select_db("Regis") or die(mysql_error()); $m=$_POST['message']; if (isset($_POST['submit'])) { // makes sure they filled it in // checks it against the database $check = mysql_query("SELECT * FROM registration WHERE username = '".$_POST['username']."'")or die(mysql_error()); //Gives error if user dosen't exist $check2 = mysql_num_rows($check); if ($check2 == 0) { echo("<SCRIPT LANGUAGE='JavaScript'>window.alert('That user does not exist in our database')</SCRIPT>") ?> <html><head></head><body> <form name="register" method="post" action="login.php" onsubmit="return a()"> <table border='0'> <input type="hidden" name="message" value="<?php echo $m;?>"> <tr><td>Username:</td><td><input type="text" name="username" maxlength="60"></td></tr> <tr><td>Password:</td><td><input type="password" name="pass" maxlength="10"></td></tr> <tr><td>Confirm Password:</td><td><input type="password" name="pass2" maxlength="10"></td></tr> <tr><th colspan=2><input type="submit" name="sub" value="Register"></th></tr></table> </form> </body> </html> <? while($info = mysql_fetch_array( $check )) { $_POST['pass'] = stripslashes($_POST['pass']); $info['password'] = stripslashes($info['password']); $_POST['pass'] = md5($_POST['pass']); } } } else { ?> <html> <head> <script type="text/javascript"> function addsmiley(code) { var pretext = document.smile.message.value; this.code = code; document.smile.message.value = pretext + code; } function a() { var x = document.smile.message.value; if(x=="") { alert("Please insert an message!"); return false; } } </script> <style type="text/css"> body{ background-color: #d8da3d } </style> </head> <body> <form name="smile" method="post" action="registration.php" onSubmit="return a()" > <input type="hidden" name="message" value="<?php echo $m;?>"> Your message:<br><textarea name='message' cols='40' rows='2'></textarea><br> <img src="smile.gif" alt=":)" onClick="addsmiley(':)')" style="cursor:pointer;border:0" /> <img src="blush.gif" alt=":)" onClick="addsmiley('*blush*')" style="cursor:pointer;border:0" /> <input type='submit' name='submit' value='Set Name' class='biasa' ></form> <br> <br> </body> </html> <?php } ?> im doing if statments if the $check2==0 it will show the registration form and else it will show the form name="smile" method="post" action="registration.php" onSubmit="return a()" > <input type="hidden" name="message" value="<?php echo $m;?>"> Your message:<br><textarea name='message' cols='40' rows='2'></textarea><br> <img src="smile.gif" alt="" onClick="addsmiley('')" style="cursor:pointer;border:0" /> <img src="blush.gif" alt="" onClick="addsmiley('*blush*')" style="cursor:pointer;border:0" /> <input type='submit' name='submit' value='Set Name' class='biasa' ></form> but my problem is it cannot direct to else matter although the name is already in database may i know which error is wrong or the if statement is wrong need help in if statement i will use it wordpress i am semi brand new in php and html i forged it with the help of c and c ++ visual basic LOL and some tutorial but did not work if any one can help making it work <?php $Shreef = <?php echo "get_post_meta($post->ID, 'sub', true);" ?> if ($Shreef=="Subbed"){ <font color="green"> <?php echo "get_post_meta($post->ID, 'sub', true);" ?> </font> } else { if ($Shreef=="Raw") <font color="red"> <?php echo "get_post_meta($post->ID, 'sub', true);" ?> </font> else { <?php echo "get_post_meta($post->ID, 'sub', true);" ?>} } ?> Hello I'm hoping someone here can help me with this. I know very little PHP I'm afraid but I think what I want to do is fairly basic and should be relatively simple. I have a footer which is referenced on each page of the site with <?php include($DOCUMENT_ROOT."/includes/php/footer.php"); ?> Within the footer I want it so that if it's the home page (default.php) it displays just the footer but for any other page I want it to display a Div and then the footer. Here is what I have so far but it isn't working: <?php if ($_SERVER['REQUEST_URI'] == "default.php") { ?> <!--Home Page Footer--> <div class="footer"> <div class="footer1"> </div> <div class="footer2"> </div> <div class="footer3"> </div> <div class="footerLinks"> <?php include($DOCUMENT_ROOT."/includes/php/bottomlinks.php"); ?> </div> <div class="footer4"> </div> </div> <?php } else { ?> <!--Blue Footer Image--> <div class="footer2"> </div> <!--Footer--> <div class="footer"> <div class="footer1"> </div> <div class="footer2"> </div> <div class="footer3"> </div> <div class="footerLinks"> <?php include($DOCUMENT_ROOT."/includes/php/bottomlinks.php"); ?> </div> <div class="footer4"> </div> </div> <?php } ?> I don't know that the request uri address is correct but when I've tried to use 'echo $_SERVER['REQUEST_URI']' to find out what it should be I can't get that to work either. I'm new here, this is my first post. Sorry if it's too basic or I've made a forum faux pas. Any help would be extremely appreciated. Good morning,
I am trying to return specific values depending on the value of the WJCStatusID, for example if WJCStatusID = < 4 but > 2 return "In production"
SQL QUERY:
SELECT tblWJCItem.AddedDescription, tblWJC.WJCPrefix + Convert(Varchar(10),tblWJC.WJCNo) AS OurRef, tblWJCItem.MaterialName, tblStockFamily.StockFamily, tblWJCItem.WeightToSend, tblWJC.DateCreated, tblWJC.WJCStatusID FROM tblWJC INNER JOIN tblWJCItem ON tblWJC.WJCID = tblWJCItem.WJCID INNER JOIN tblStockFamily ON tblWJCItem.ProductFamilyID = tblStockFamily.StockFamilyID IF (tblWJC.WJCStatusID) < 2 THEN 'Pre Production' ELSE IF (tblWJC.WJCStatusID) < 4 THEN 'In Production' ELSE IF (tblWJC.WJCStatusID) > 4 THEN 'Ready To Ship' ELSE 'Awaiting Lab Results';I am quite new to the world of mssql so I maybe doing something wrong which is quite simply to fix. Can any body help? Trying to code a first fit algorithm (explanation here). It doesn't output everything correctly at the end. There probably is an easier way to achieve this, but I need to do it using do and while statements. From the output I only get the first array, none of the others display. function first_fit(&$arr, &$max) { $bin = array(array(), array(), array(), array(), array(), array(), array(), array(), array() ,array() ); $i=0; $j=0; do { do { if (array_sum($bin[$j])+$arr[$i] <= $max) {$bin[$j][] = $arr[$i]; $k=1; } $j++; } while($k = 0); $i++; $j=0; } while($i<=9); outputarray($bin[0]); outputarray($bin[1]); outputarray($bin[2]); outputarray($bin[3]); outputarray($bin[4]); outputarray($bin[5]); outputarray($bin[6]); outputarray($bin[7]); outputarray($bin[8]); outputarray($bin[9]); } The function outputarray() just prints the array in a nicely formatted way. Any help would be much appreciated. |