PHP - No Image Statement
I have a form where it will display the image that was uploaded but if there is no image uploaded I would like it to say "No Image"
I have this Code: [Select] <img src="../<? echo $rows['imageurl6']; if(!empty($rows)){echo 'No Image';}?>" width="200" /> but it doesn't work. Can someone help me please? Thanks Similar Tutorialsdoes anyone know how to do an if statement in the middle of a gd image so that if a dropdown box is selected it draws different lines... Code: [Select] <label for="height"></label> <select name="height" id="height"> <option value="2.4">2.4</option> <option value="2.7">2.7</option> </select> </form> <?php require_once('./include/connection.php'); ?> <?php header ("Content-type: image/png"); ?> <?php $x1=$_GET['x1']; $x2=$_GET['x2']; $y1=$_GET['y1']; $y2=$_GET['y2']; $im = @ImageCreate (800, 600) or die ("Cannot Initialize new GD image stream"); $background_color = ImageColorAllocate ($im, 255, 255, 255); $line_color = ImageColorAllocate ($im, 0, 0, 0); // imageline ($im,$x1,$y1,$x2,$y2,$text_color); //front base line if "height" = "2.4" imageline ($im,50,550,500,550,$line_color); else imageline ($im,50,200,500,200,$line_color); endif //front left vertical imageline ($im,50,550,50,200,$line_color); //front right vertical imageline ($im,500,550,500,200,$line_color); //bottom of apex imageline ($im,50,200,500,200,$line_color); //left roof line imageline ($im,50,200,275,100,$line_color); //right roof line imageline ($im,500,200,275,100,$line_color); ImagePng ($im); ?> I am still a novice, but I am working on an idea.
I have a table with a field: judges_ccpadv that contains only 3 possible characters = B, R, or N
My desire is to display a simple little icon for any of those 3 characters.
I tried:
if ($data['judges_ccpadv'] = "B") { echo "<img src='images/b.png'>\n"; } if ($data['judges_ccpadv'] = "R") { echo "<img src='images/r.png'>\n"; } if ($data['judges_ccpadv'] = "N") { echo "<img src='images/n.png'>\n"; } The output is any image that is not in the if statement. So if "B" is in field, r.png and n.png are both displayed. What am I doing wrong here? Assistance is greatly appreciated. Thanks! Hi,
I have the following script which displays a banner image based on a cookie. It also displays a banner if there is no cookie. What I would like to do is to display the banners based on cookies, but instead of displaying the "no-cookie.gif" image, I want to insert some HTML content.
What would be the best way to do this?
$( document ).ready(function() {Thanks! Hi, I've got a FORM Setup. The form has a current image and an option to add a new image (In place of that image) The form fields in question are : Code: [Select] <input type="hidden" name="image_url" value="<?php echo $row_select_propertyimages['image_url']; ?>" /> <input type="file" name="new_image_url" class="inputfile" /> I've setup an IF Statement, to check that if new_image_url ISNT set, then to keep the current image. Otherwise, overwrite it with new_image_url. When I dont choose to upload a new file, The code works correctly. The code is as follows. Code: [Select] if(empty($_POST['new_image_url'])) { $image_url = $row_select_propertyimages['image_url']; } else { $image_url = $_FILES['new_image_url']; } The data then gets input to a Database. But at the moment, It is not overwriting what is currently there. Can anyone help me on this? My full code is : Code: [Select] <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $colname_select_propertyimages = "-1"; if (isset($_GET['image_id'])) { $colname_select_propertyimages = $_GET['image_id']; } mysql_select_db($database_db_connect, $db_connect); $query_select_propertyimages = sprintf("SELECT * FROM image WHERE image_id = %s", GetSQLValueString($colname_select_propertyimages, "int")); $select_propertyimages = mysql_query($query_select_propertyimages, $db_connect) or die(mysql_error()); $row_select_propertyimages = mysql_fetch_assoc($select_propertyimages); $totalRows_select_propertyimages = mysql_num_rows($select_propertyimages); mysql_select_db($database_db_connect, $db_connect); $query_select_property = "SELECT property.property_id, property.property_name FROM property "; $select_property = mysql_query($query_select_property, $db_connect) or die(mysql_error()); $row_select_property = mysql_fetch_assoc($select_property); $totalRows_select_property = mysql_num_rows($select_property); $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "addproperty")) { if(empty($_POST['new_image_url'])) { $image_url = $row_select_propertyimages['image_url']; } else { $image_url = $_FILES['new_image_url']; } echo $image_url; $updateSQL = sprintf("UPDATE image SET image_url=%s, image_desc=%s, image_disphome=%s, image_property_id=%s WHERE image_id=%s", GetSQLValueString($image_url, "text"), GetSQLValueString($_POST['image_desc'], "text"), GetSQLValueString(isset($_POST['image_disphome']) ? "true" : "", "defined","'Y'","'N'"), GetSQLValueString($_POST['image_property_id'], "int"), GetSQLValueString($_POST['image_id'], "int")); mysql_select_db($database_db_connect, $db_connect); $Result1 = mysql_query($updateSQL, $db_connect) or die(mysql_error()); // $updateGoTo = "success_editproperty.php"; // if (isset($_SERVER['QUERY_STRING'])) { // $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; // $updateGoTo .= $_SERVER['QUERY_STRING']; // } // header(sprintf("Location: %s", $updateGoTo)); } ?> Many Thanks in advance. 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 need help with my if/else statement. Code: [Select] function show_list() { $query = "SELECT show_id,show_name,host,description_short,show_graphic1 FROM shows"; $result = mysql_query($query) or die(mysql_error()); echo "<table>"; while($row = mysql_fetch_array($result)) { echo "<tr> <td rowspan='3' width='155' class='show_image'> <a href='". $site ."show_page.php?show_id=". $row['show_id'] ."'> <img src='". $site ."images/". $row['show_graphic1'] ."' height='150' width='150'></img></a> </td> <td class='show_name'> <h1>"; if ($row['host'] == "") { echo $row['show_name']" with " $row['host']; } else { echo $row['show_name']; } echo " </h1> </td> </tr> <tr> <td height='100'>" . $row['description_short'] . "</td> </tr> <tr> <td align='right'> <a href='". $site ."show_page.php?show_id=". $row['show_id'] ."'>More Info</a> </td> </tr>"; } echo "</table>"; } This function is for a page showing a list of shows from a database. Not all shows have a host. So it does not need to show "with host name" for those shows. I tried if / else statement stating that if there "is" data in the row to display one thing and if there "is not" data in the row to display another. Here is that piece of code. Code: [Select] if ($row['host'] == "") { echo $row['show_name']" with " $row['host']; } else { echo $row['show_name']; } I keep getting this error "Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/ansonb/lwr_config.php on line 46" What am I doing wrong ? I'm sure it is something simple, I just can't figure it out. 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? I think I know the answer to this, but it would make things easier if I could do what I think I can't. Can I use LIKE and NOT LIKE in an if statement? Doesn't seem to be working for me. Code: [Select] <?php //$rightlic is a twelve character string ending either P00, P01, V00, or V01. I want to do different things based on V or P if ($rightlic not like '%V00' AND $rightlic not like '%V01'){ echo "<br>purchaser ran demo as public but is now trying to purchase a private account. Stop the process."; exit; } ?> Can I do something like this or do I have to separate the string and look for the last characters that way? Thanks in advance for any help. Hi I am trying to perform an echo yes if field from query is equal to one or no if anything else. See the code below, Now its erroring saying unexpected t variable in string and its also saying expecting ' It seems to be erroring at the start of my IF statement. So can anyone please help with what I have done wrong. This will be my first personal written IF statement so if it is miles off i apologise. <?php $qGetCat = ("SELECT * FROM category ORDER BY `id`"); $rGetCat = mysql_query($qGetCat) or die(mysql_error()); while($Cat = mysql_fetch_assoc($rGetCat)) { ?> <td height="31" align="left" nowrap="nowrap"><?= $Cat['id'] ?></td> <td align="left" nowrap="nowrap"><?= $Cat['cat1'] ?></td> <td align="left" nowrap="nowrap"> <?php if $Cat['top']='1' { echo "Yes";} else { echo "No";} ?> </td> <td><a href="updatetopcategory.php?=<?= $Cat['id'] ?>"><img src="../images/Edit.png" width="29" height="29" /></a></td> <td><img src="../images/delete.jpg" width="29" height="29" /></td> <? } ?> 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 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 { } } Hi all, I have the below which triggers an alert box when the user is redirected to the index page. <?php if(!empty($_SESSION['reg'])) { echo '<div id="alert">' . $_SESSION['reg'] . '</div>'; unset($_SESSION['reg']); } if(!empty($_SESSION['fail'])) { echo '<div id="alertr">' . $_SESSION['fail'] . '</div>'; unset($_SESSION['fail']); } if(!empty($_SESSION['logged'])) { echo '<div id="alertr">' . $_SESSION['logged'] . '</div>'; unset($_SESSION['logged']); } if(!empty($_SESSION['failedlog'])) { echo '<div id="alertr">' . $_SESSION['failedlog'] . '</div>'; unset($_SESSION['failedlog']); }?> It only works when session ['reg'] contains a value. I guess I can not use if statements in this way but not quite sure what I should be using? Many Thanks 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"; ?> hi how do u do a if statement so that if <a href="TaxiEntry1.php?Quote_ID='.$qid.'">Accept</a> is clicked then update this field in this table } thanks 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);" ?>} } ?> hi all I am trying to process a result from a query but cant use a echo in a while statement Here is the code I am trying to get the result from each row in the table and then display them I get the error Parse error: syntax error, unexpected T_ECHO in C:\wamp\www\blackrain\Resources\read.php on line 13 <?php $link = mysql_connect('localhost', 'root', ''); if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db("php"); $rs = "SELECT `id`, `title`, `author`, `date`, `imageUrl`, `text` FROM `items` "; $rs_return = mysql_query($rs) or trigger_error($rs . ' has encountered an error: <br />'. mysql_error()); while($obj = mysql_fetch_array($rs_return, MYSQL_ASSOC)) {" <h1>"+ echo $obj['title']; +"</h1> <div id="+"wrapper"+"> <div id="text"> <h4>Posted:"+ echo $obj['author'];+"By:"+ echo $obj['date'] +"</h4> <p class="p3"> <span> <img class="+"alignright"+"src="+ echo $obj['imageUrl'];+"> </img>"+ echo $obj['text'];+"</span></p>" } ?> im trying to make it so before it inserts the comment and username into the database it check if the username is active: 0 or 1. if it is 0 then die but if active then its all good lol. what i have now lets anybody comment. to me it looks perfect ? =[ Code: [Select] if (isset($_POST['submit'])) { $check = mysql_query("SELECT active FROM users WHERE active ='1'") or die(mysql_error()); $check2 = mysql_num_rows($check); if ($check2 != 1) { die('You are Not allowed to comment untill your account is activated.'); }else{ $comment = mysql_real_escape_string(stripslashes(trim($_POST['comment']))); $insert = "INSERT INTO homecomments (username, comment) VALUES ('[$username]', '[$comment]')"; $add_member = mysql_query($insert); { echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=index.php\">"; } } } 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? 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. |