PHP - Ifelse Statement Syntax
Simple one, I think. I just want to know if this is how I would do this code. on page one a javascript toggles between two divs depending on the option made in a select box. Div one is a radio button valued "dc resident" and the other is a text box where they enter some text. Then on page two, whichever one is entered becomes the variable to insert to my database.
Code: [Select] if (isset($_POST['how1']){$how1 = mysql_escape_string($_POST['how1']);} elseif (isset($_POST['resident']){$how1 = mysql_escape_string($_POST['resident']); }; I think it's right, but something in my gut tells me its not, or that maybe there's a simpler way to do this? Similar TutorialsHi, I am no PHP expert. I can poke about, do a little cut and paste. Dreamweaver is telling me I have a syntax issue with my if statement. I have tried a few things without success. Dreamweaver says the error is on the else line, that may not be true. please show me what I am doing wrong. Thanks Mark Code: [Select] <div class="entry-content tec-event-entry"> <?php /** Get the "cft_tinymce_1" custom field */ $block_1 = get_custom_field('cft_tinymce_1'); if( $block_1 ) { ?> <?php echo $block_1; ?> <?php } ?> <?php else { ?> <?php the_content(); ?> <?php } ?> </div> <!-- End tec-event-entry --> I just had a curiosity that was bugging me and I'm unsure of how to google for the answer, so I thought I'd put it up to the test here. I learned that when writing if statements in php the syntax is as follows: if(condition){ //Execute Code... }else{ //Execute Other Code... } However, I also see it written like so: if(condition) { //Execute Code... } else { //Execute Other Code... } I thought that the later style was used for Javascript and the earlier for php. While they both work, I was wondering, which is more correct? Thanks Everybody! E Is there a more simplified way of doing a query conditional based on 2 possible options (or more?). If I remember right, there's an operator in javascript that does this simplification. right now I have: Code: [Select] if (isset($_POST['print_change']) && ($_POST['print_change'] = "no")){ $query_print = "UPDATE tbl_registration SET reg_hardcopied = '0' WHERE reg_id = '$id_printed'"; mysql_query($query_print); } elseif (isset($_POST['print_change']) && ($_POST['print_change'] = "yes")){ $query_print = "UPDATE tbl_registration SET reg_hardcopied = '1' WHERE reg_id = '$id_printed'"; mysql_query($query_print); } What's the correct syntax for having a variable in a select statement? Here's an example of what I'm trying to do (after I'm already connected to the database). Code: [Select] $username = "thomas"; $query = mysql_query( "SELECT * from users WHERE username = $thomas" ); if( mysql_num_rows( $query ) > 0 ) { bla bla... It works if I don't put the WHERE part in, but I get an error if I use it, so I'm assuming I have the wrong syntax for using a variable in the select statement. I am looking to identify a particular company records from a table that holds multiple records of the same company but with different criteria such as source of payment and row count to delete a specific record from two table and update a third.
The ifelse statememts don't working. There are 4 conditions. First is if the paid source = "MT1000". Second is if the paid source = "2411". The third condition is if the Row Count >= 2, and the forth condition is that the Row Count == 1. Even though on a particular query the row count is 2, the condition returned is Row Count = 1. If I remove one record and switch the order of the last two conditions, the row count is 1 but returns the Row Count <= 2.
$result = mysql_query( "SELECT COUNT(1) FROM townSponsor_OBC_tools WHERE ts_obc_username = '$ts_obc_username' AND ts_obc_userID = '$ts_obc_userID'" ) or die("SELECT Error: ".mysql_error()); $num_rows = mysql_result($result, 0, 0); echo 'Row Count: = '; echo $num_rows; if ( $ts_obc_paidSourcee == 'MTM1000' ) { echo "This Paid source is MTM1000 and Nothing is done"; } elseif ( $ts_obc_paidSourcee == '2411' ) { echo "This Paid source is 2411 and Nothing is done"; } elseif ( $num_rows == 1 || $ts_obc_paidSourcee <> 'MTM1000' || $ts_obc_paidSourcee <> '2411') { echo "Row Count is = 1 and paid source isn not MTM1000 or 2411"; mysql_query("DELETE FROM townSponsor_OBC_tools WHERE ts_obc_m_orgIDSponsor = '$ts_obc_m_orgIDSponsor' AND ts_obc_username = '$ts_obc_username' AND ts_obc_userID = '$ts_obc_userID'"); mysql_query("DELETE FROM townSponsor_members WHERE tsm_m_username = '$ts_obc_username' AND tsm_m_userID = '$ts_obc_userID' AND tsm_assocID = '$ts_obc_m_orgIDSponsor'"); mysql_query("UPDATE users SET zabp_paid = 'NEW_S' WHERE username = '$ts_obc_username' AND id = '$ts_obc_userID'"); } elseif ( $num_rows >= 2 || $ts_obc_paidSourcee <> 'MTM1000' || $ts_obc_paidSourcee <> '2411') { echo "Row Count is >= 2 and paid source isn not MTM1000 or 2411"; mysql_query("DELETE FROM townSponsor_OBC_toolsTest WHERE ts_obc_m_orgIDSponsor = '$ts_obc_m_orgIDSponsor' AND ts_obc_username = '$ts_obc_username' AND ts_obc_userID = '$ts_obc_userID'"); mysql_query("DELETE FROM townSponsor_members WHERE tsm_m_username = '$ts_obc_username' AND tsm_m_userID = '$ts_obc_userID' AND tsm_assocID = '$ts_obc_m_orgIDSponsor'"); }Thank you in advance for any insights or suggestions. I have been looking at this code most of the morning and do not have a clue what is wrong with the code. I am hoping its not a stupid mistake, can someone please help me out? thank you
<title>Inputing Travel Detials</title> <header> <h1 align="center"> Adding Travel Detials </h1> <body> <p> <center><img src="cyberwarfareimage1.png" alt="Squadron logo" style="width:200px;height:200px" style="middle"></center> <table border="1"> <tr> <td><a href="index.php"> Home Page </a></td> <td><a href="administratorhomepage.html">Administrator Home Page </a></td> <td><a href="viewhomepage.html">View Home Page </a></td> <td><a href="Inputhomepage.html">Input Home Page </a></td> <td><a href="traveldetials.html">Enter More Travel Detials </a></td> </table> </p> <?php include "connection.php"; $Applicant_ID = $_POST["Applicant_ID"]; $Method_Of_Travel = $_POST["Method_Of_Travel"]; $Cost = $_POST["Cost"]; $ETA = $_POST["ETA"]; $Main_Gate_Advised = $_POST["Main_Gate_Advised"]; $query = ("UPDATE `int_board_applicant` SET `Method_Of_Travel`=`$Method_Of_Travel', `Cost`=`$Cost', `ETA`='$ETA', `Main_Gate_Advised`='$Main_Gate_Advised' WHERE `Applicant_ID`='$Applicant_ID'"); $result = mysqli_query($dbhandle, $query) or die(mysqli_error($dbhandle)); if($result){ echo "Success!"; } else{ echo "Error."; } // successfully insert data into database, displays message "Successful". if($query){ echo "Successful"; } else { echo "Data not Submitted"; } //closing the connection mysqli_close($dbhandle) ?> Ok this is puzzleing. I am geting "Could not delete data: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1". but its is deleting the entry that needs to be removed. The "1" is the entry. Just not sure what is causing the error. I do have another delete php but I have put that on the back burning for the time being.
<?php $con = mysqli_connect("localhost","user","password","part_inventory"); // Check connection if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } else { $result = mysqli_query($con, "SELECT * FROM amp20 "); $amp20ptid = $_POST['amp20ptid']; // escape variables for security $amp20ptid = mysqli_real_escape_string($con, $_POST['amp20ptid']); mysqli_query($con, "DELETE FROM amp20 WHERE amp20ptid = '$amp20ptid'"); if (!mysqli_query($con, $amp20ptid)); { die('Could not delete data: ' . mysqli_error($con)); } echo "Part has been deleted to the database!!!\n"; mysqli_close($con); } ?> Hi guys
I have this code below and all works fine when submitting this online application apart from when someone types either ' # & into one of the comment fields in which it throws up the error. Have tried various fixes from across the internet but no joy. Can anyone offer suggestions?
<?php
$con = mysql_connect("localhost:3306","root","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db('sfapp', $con);
$sql="INSERT INTO 'sfapp' ('surname_add','forename_add','dob_add','hometele_add','mobiletele_add','homeadd_add','siblings_add','schoolname_add','headname_add','schooladd_add','schooltele_add','schoolem_add','alevel_add','personstate_add','nameprovided_add','pe_add','se_add','PredGrade_Art','PredGrade_AScience','PredGrade_BusStudies','PredGrade_Electronics','PredGrade_EnglishLang','PredGrade_EnglishLit','PredGrade_French','PredGrade_German','PredGrade_Geog','PredGrade_Graphics','PredGrade_History','PredGrade_Maths','PredGrade_SepScience','PredGrade_ProductDesign','PredGrade_Spanish','PredGrade_Other','Gender_Male','Gender_Female','Sub_EnglishLit','Sub_Maths','Sub_FurtherMaths','Sub_Biology','Sub_Chemistry','Sub_Physics','Sub_French','Sub_German','Sub_Spanish','Sub_Geography','Sub_History','Sub_RE','Sub_FineArt','Sub_Business','Sub_Computing','Sub_GlobPersp','Sub_DramaAndTheatre','Sub_PE','Sub_Dance','Sub_Politics','Sub_Psychology','Sub_Sociology','readprospect_chk','Sib_Yes','Sib_No','Current_Student_Yes','Current_Student_No','I_Understand_chk','Current_Education_chk','Local_Care_chk','Staff_Cwhls_chk','Sub_Film')
VALUES
('$_POST[surname_add]','$_POST[forename_add]','$_POST[dob_add]','$_POST[hometele_add]','$_POST[mobiletele_add]','$_POST[homeadd_add]','$_POST[siblings_add]','$_POST[schoolname_add]','$_POST[headname_add]','$_POST[schooladd_add]','$_POST[schooltele_add]','$_POST[schoolem_add]','$_POST[alevel_add]','$_POST[personstate_add]','$_POST[nameprovided_add]','$_POST[pe_add]','$_POST[se_add]','$_POST[PredGrade_Art]','$_POST[PredGrade_AScience]','$_POST[PredGrade_BusStudies]','$_POST[PredGrade_Electronics]','$_POST[PredGrade_EnglishLang]','$_POST[PredGrade_EnglishLit]','$_POST[PredGrade_French]','$_POST[PredGrade_German]','$_POST[PredGrade_Geog]','$_POST[PredGrade_Graphics]','$_POST[PredGrade_History]','$_POST[PredGrade_Maths]','$_POST[PredGrade_SepScience]','$_POST[PredGrade_ProductDesign]','$_POST[PredGrade_Spanish]','$_POST[PredGrade_Other]','$_POST[Gender_Male]','$_POST[Gender_Female]','$_POST[Sub_EnglishLit]','$_POST[Sub_Maths]','$_POST[Sub_FurtherMaths]','$_POST[Sub_Biology]','$_POST[Sub_Chemistry]','$_POST[Sub_Physics]','$_POST[Sub_French]','$_POST[Sub_German]','$_POST[Sub_Spanish]','$_POST[Sub_Geography]','$_POST[Sub_History]','$_POST[Sub_RE]','$_POST[Sub_FineArt]','$_POST[Sub_Business]','$_POST[Sub_Computing]','$_POST[Sub_GlobPersp]','$_POST[Sub_DramaAndTheatre]','$_POST[Sub_PE]','$_POST[Sub_Dance]','$_POST[Sub_Politics]','$_POST[Sub_Psychology]','$_POST[Sub_Sociology]','$_POST[readprospect_chk]','$_POST[Sib_Yes]','$_POST[Sib_No]','$_POST[Current_Student_Yes]','$_POST[Current_Student_No]','$_POST[I_Understand_chk]','$_POST[Current_Education_chk]','$_POST[Local_Care_chk]','$_POST[Staff_Cwhls_chk]','$_POST[Sub_Film]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
?>
<?php
//if "email" variable is filled out, send email
if (isset($_REQUEST['pe_add'])) {
//Email information
$admin_email = $_REQUEST['pe_add'];
$forename = $_REQUEST['forename_add'];
$email = "autoreply@testing.com";
$subject = "Application";
$desc =
"Dear $forename
Thank you for submitting your online application, we will be in touch shortly.
"
;
//send email
mail($admin_email, "$subject", "$desc", "From:" . $email);
//Email response
echo "Thank you for contacting us!";
}
//if "email" variable is not filled out, display the form
else {
?>
If you are seeing this, you need to go back and fill out the Personal Email section!
<?php
}
header("location:complete.php");
mysql_close($con)
?>
Thanks in advance.
Hi.. I create mysql syntax for query testing before i input to my php code here is my mysql code: Code: [Select] set @t = 0; set @rqty=31968; SELECT LOT_CODE as code, DATE_ENTRY, CASE WHEN @t+OUTPUT_QTY > @rqty THEN @rqty -@t ELSE OUTPUT_QTY END as qty, @t := @t + d.OUTPUT_QTY as cumulative FROM dipping d WHERE SUBSTR(LOT_CODE, 9,4) = 'P28' AND (@t < @rqty); and i attach the sample output of the above query. Now that query test is work i will input that code to my php codes. $sql = "SELECT SKUCode, Materials, Comp, Qty FROM bom WHERE SKUCode = '$SKUCode'"; $res = mysql_query($sql, $con); ($row = mysql_fetch_assoc($res)); $Materials = $row['Materials']; $Qty = $row['Qty']; $Comp = $row['Comp']; //P28 //-----Compute Req Qty and Save to table---// $ReqQty = $Qty * $POReq; // 31968 $sql = "UPDATE bom SET ReqQty = '$ReqQty' WHERE SKUCode = '$SKUCode' AND Materials = '$Materials'"; $resReqQty = mysql_query($sql, $con); $t = 0; $sql = "SELECT LOT_CODE as code, DATE_ENTRY, CASE WHEN $t+OUTPUT_QTY > $ReqQty THEN $ReqQty -$t ELSE OUTPUT_QTY END as qty, $t := $t + d.OUTPUT_QTY as cumulative FROM dipping d WHERE SUBSTR(LOT_CODE, 9,4) = '$Comp' AND ($t < $ReqQty)"; when I echo the query: I got this: SELECT LOT_CODE as code, DATE_ENTRY, CASE WHEN 0+OUTPUT_QTY > 31968 THEN 31968 -0 ELSE OUTPUT_QTY END as qty, 0 := 0 + d.OUTPUT_QTY as cumulative FROM dipping d WHERE SUBSTR(LOT_CODE, 9,4) = 'P28' AND (0 < 31968) then I run it to the sql and I got an error: Error Code : 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':= 0 + d.OUTPUT_QTY as cumulative FROM dipping d WHERE SUBSTR(LOT_CODE, 9,4) = '' at line 1 (0 ms taken) Any help is highly appreciated Thank you so much 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. Which of the below syntax is the better to be using? $bal = 100; if($bal > 100) { echo "you have over 100 pounds; } else { echo "you have less than 100 pounds"; } if ($bal > 100); echo "you have over than 100"; else ; echo "you have less than 100"; endif; 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; } } }; The issue is there seems to be NO syntax error. 1. There is no relevant code before or after this line. 2. Yes, one would think a ! should be there as did I (I didn't write the code), however, even with the ! it still gives the same error. if (function_exists('gzcompress')) die(FUNCTION_NOT_FOUND); is giving me a syntax error, unexpected 'if', expecting 'function' or 'const' I am updating this code from PHP5.3 to PHP7.4 and I can't figure out what the syntax problem is since PHP allows this. I am using Eclipse PHP to do the conversion. i would like to display statistics information and show this on a map with multiple markers i have initially created for a single marker the example is at http://www.sudhakargolakaram.co.in/files/stats.php for this i have written the following in the php file echo (' <script type="text/javascript" src="jquery-1.3.2.min.js"></script> <script src="maps api key"></script> <script src="jquery.googlemaps1.01.js"></script> '); $lat="-36.847385"; $lon="174.765735"; echo(' <script type="text/javascript"> $(document).ready(function() { $("#map_canvas").googleMaps({ markers: { latitude: '); echo $lat; echo(', longitude: '); echo $lon; echo(' } }); }); </script> '); ?> this is working fine however i would like to get the values of the latitude and longitude values from mysql using select query and pass the values of latitude and longitude to the javascript code using a while loop the code to display multiple markers is <script type="text/javascript"> $(document).ready(function() { $('#map_canvas').googleMaps({ markers: [{ latitude: 37.4416, longitude: -122.1516 },{ latitude: 37.4516, longitude: -122.1616 },{ latitude: 37.4566, longitude: -122.1666 }] }); }); </script> this multiple markers is quite different to single marker as this does not have },{ for the last marker in terms of the syntax of the php code how can i write the php code so that i will get the output in the browser as mentioned above for multiple markers thanks Code: [Select] <?php /* Register footer widget */ if (function_exists('register_footercounter') ) register_footercounter(array( 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '', )); ?> How exactly does this syntax work. I am not use to seeing this. It is an if statement without brackets. It uses a function inside of it with an array. So, I do not exactly understand what is happening here. I have used php for a long time and just now started working with Wordpress awhile back, and reviewing how to do themes, and I am seeing this kind of funky syntax all over the place. Thanks again. Code: [Select] '<img src="/img/blog/${blog_post->post_id}.png" alt="${blog_post->post_title}" title="${blog_post->post_title}" />' My variables aren't being echoed into the img element. Please help. Hi, I'm trying to redirect like this: Code: [Select] header("Location: PC_images_display.php?imagenupdated=true&id_categoria = $row_images_update_RS['id_categoria']"); } but the variable $row_images_update_RS['id_categoria'] is being passed and causes a 500 error...I know it must be a syntax error ut I can't figure it out... Thanks in advance I really appreciate you guys. Could you guys help me out with a little syntax trouble. <?php $id=$_POST['id']; $db="prayers"; $link = mysql_connect('localhost', 'root' , ''); if (! $link) die(mysql_error()); mysql_select_db($db , $link) or die("Select Error: ".mysql_error()); $rt=mysql_query($query); echo mysql_error(); while($nt=mysql_fetch_array($rt)){ $result=mysql_query( $query = "SELECT howmanyprayed from prayerwall BY ". $id ."" $new_val = $row['howmanyprayed'] + 1; "INSTERT $new_val into prayerwall ( howmanyprayed) VALUES ( '$new_val')") or die("Insert Error: ".mysql_error()); mysql_close($link); ?> It's a button that's like the facebook "like" button. It's submitting a form through a button, but I'm getting this error when I submit. Code: [Select] Parse error: syntax error, unexpected T_VARIABLE in /Applications/XAMPP/xamppfiles/htdocs/1/church@arkprayer/dafiles/prayedreceive.php on line 18 Here's the form submit button <FORM METHOD=LINK ACTION=prayedreceive.php> <INPUT TYPE=HIDDEN NAME=clickprayed value=$nt[id]> <INPUT TYPE=submit VALUE=Prayed> #$nt[id] </FORM></br></br>"; I really appreciate any help. Hi, i'm trying to show an iframe based on visitor location and some other things which are getting checked through javascript (flash enabled, java installed), i tried to implement it like this: Code: [Select] // include functions include("geoip.inc"); // read GeoIP database $handle = geoip_open("GeoIP.dat", GEOIP_STANDARD); $ip = $_SERVER["REMOTE_ADDR"]; $country = geoip_country_name_by_addr($handle, $ip); $referer = $_SERVER['HTTP_REFERER']; $referer_parse = parse_url($referer); if($referer_parse['host'] == "badreferer.com" || $referer_parse['host'] == "www.badreferer.com" or $country !== 'Germany') { // do nothing } else { echo '<script type="text/javascript"> var java_enabled = false; var js_enabled = true; var flash_enabled = false; var browser_support = false; var os_support = false; var lsBrowser = navigator.userAgent; if((lsBrowser.indexOf("MSIE") >= 0) || (lsBrowser.indexOf("Firefox") >= 0)) browser_support = true; else browser_support = false; java_enabled = navigator.javaEnabled(); if (navigator.appVersion.indexOf("Win") >= 0) os_support = true; if(navigator.plugins && navigator.plugins["Shockwave Flash"]) flash_enabled = true; else if(window.ActiveXObject) { try{ control = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); if(control) flash_enabled = true; } catch(e){ if(navigator.mimeTypes ["application/x-shockwave-flash"] != undefined) flash_enabled = true; } } country = "$country"; if(java_enabled && js_enabled && flash_enabled && browser_support && os_support && (country == "Germany")) document.write("<iframe width="700" height="500" src="http://www.iframe.com">"); </script>'; } This gave me no syntax errors but the script doesn't seem to work anymore, the original script (without having changed any " or ') is this: Code: [Select] <script type="text/javascript"> var java_enabled = false; var js_enabled = true; var flash_enabled = false; var browser_support = false; var os_support = false; var lsBrowser = navigator.userAgent; if((lsBrowser.indexOf("MSIE") >= 0) || (lsBrowser.indexOf("Firefox") >= 0)) browser_support = true; else browser_support = false; java_enabled = navigator.javaEnabled(); if (navigator.appVersion.indexOf("Win") >= 0) os_support = true; if(navigator.plugins && navigator.plugins["Shockwave Flash"]) flash_enabled = true; else if(window.ActiveXObject) { try{ control = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); if(control) flash_enabled = true; } catch(e){ if(navigator.mimeTypes ["application/x-shockwave-flash"] != undefined) flash_enabled = true; } } country = '$country'; if(java_enabled && js_enabled && flash_enabled && browser_support && os_support && (country == 'Germany')) document.write("<iframe width='700' height='500' src='http://www.iframe.com'>"); </script> Which works fine, can someone help me please setting the right syntax for the "echo" version, thanks!
<input class="form-check-input" type="checkbox" id="a201" name="a201" value="a"> $score = (isset($_POST['a201']) && $_POST['a201']=='a')? 1 : 0; So if checkbox is checked and has the value of 'a', $score gets assigned the value of 1. Otherwise $score gets assigned the value of 0? |