Nsm Posted October 5, 2013 Share Posted October 5, 2013 Hi,I can't find the error in this code: <?php $cat=$_REQUEST['cate']; if($cat==1 && $cat==2 && $cat==3 && $cat==4) { require_once('OrderStatus.php'); } elseif ($cat==5 && $cat==6) { require_once('NoVal1.php'); } ?>Error:Parse error: syntax error, unexpectedWhat am I doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/282743-parse-error-syntax-error-unexpected/ Share on other sites More sharing options...
.josh Posted October 5, 2013 Share Posted October 5, 2013 && is that really what your code is? need to change that to && Quote Link to comment https://forums.phpfreaks.com/topic/282743-parse-error-syntax-error-unexpected/#findComment-1452734 Share on other sites More sharing options...
ShivaGupta Posted October 5, 2013 Share Posted October 5, 2013 (edited) Hi, I can't find the error in this code: <?php $cat=$_REQUEST['cate']; if($cat==1 && $cat==2 && $cat==3 && $cat==4) { require_once('OrderStatus.php'); } elseif ($cat==5 && $cat==6) { require_once('NoVal1.php'); } ?> Error:Parse error: syntax error, unexpected What am I doing wrong? this is a best option to post code <> see magic <?php $cat=$_REQUEST['cate']; if($cat==1 && $cat==2 && $cat==3 && $cat==4) { require_once('OrderStatus.php'); } elseif ($cat==5 && $cat==6) { require_once('NoVal1.php'); } ?> Edited October 5, 2013 by ShivaGupta Quote Link to comment https://forums.phpfreaks.com/topic/282743-parse-error-syntax-error-unexpected/#findComment-1452737 Share on other sites More sharing options...
Nsm Posted October 5, 2013 Author Share Posted October 5, 2013 Thanks for your reply but that did no do me any good.Let me be more specific.I use existing scripts and try to modify them to my needs.I started a new project and learn as a go. What i want to chieve is the following:If sales district 1 - 4 is selected Display OrderStatus.If sales disrict 5 0r 6 is selected Display NoVal1This Is my index page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Dynamic field creation in PHP</title> <script type="text/javascript" src="jquery.js"></script> <script language="javascript"> function getXMLHTTP() { var xmlhttp=null; try { xmlhttp=new XMLHttpRequest(); } catch(e) { try { xmlhttp=new ActiveXobject("Microsoft.XMLHTTP"); } catch(e) { try { xmlhttp=new ActiveXObject("msxml2.XMLHTTP"); } catch(e1) { xmlhttp=false; } } } return xmlhttp; } var strurl="dynamic-form.php?cate="+cat; var req=getXMLHTTP(); function getCat(cat) { //alert(cat); $("#flash").show(); $("#flash").fadeIn(400).html('<img src="ajax-loader.gif" align="absmiddle"> loading.....'); var strurl="dynamic-form.php?cate="+cat; //alert(strurl); var req=getXMLHTTP(); if(req==null) { alert("browser error"); } if(req) { req.onreadystatechange=function() { if(req.readyState ==4 || req.readyState=="complete") { $("#flash").hide(); document.getElementById("ajaxresult").innerHTML=req.responseText; } } req.open("GET",strurl,true); req.send(null); } } </script> </head> <body> <div style="text-align:center;"> <div style="display:none;"><img src="ajax-loader.gif" /></div> <h1 style="color:#CCC;">VAT WORKFLOW</h1></div> <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td width="10%">TODAYS DATE</td> <td width="10%"> <?php echo date("d/m/Y"); ?> </td> <td width="25%"> </td> <td width="25%"> </td> </tr> <tr> <td width="10%">SALES DISTRICT</td> <td width="10%"><label> <select name="select" id="select" onChange="getCat(this.value)"> <option value="" selected="selected">Select Sales District</option> <option value="1">IN05</option> <option value="2">IN02</option> <option value="3">IN23</option> <option value="4">IN13</option> <option value="5">EDU</option> <option value="6">EPP</option> </select></label></td> <td width="25%"> </td> <td width="25%"> </td> </tr> <tr> <td width="1317" colspan="4"> <div id="flash"></div> <div id="ajaxresult"></div></td> </tr> </table> </body> </html> I edit the dynamic-form.php file to: <?php $cat=$_REQUEST['cate']; if($cat==1 && $cat==2 && $cat==3 && $cat==4) { require_once('OrderStatus.php'); } elseif ($cat==5 && $cat==6) { require_once('NoVal1.php'); } ?> OrderStatus.php File: <table width="100%" border="0" cellspacing="2" cellpadding="2"> <tr> <th width="10%" align="left" valign="middle"><strong>ORDER STATUS</strong></td> <th width="10%" align="left" valign="middle"><label> <select name="select" id="select"> <option value="" selected="selected">Select Order Status</option> <option value="1">Open</option> <option value="2">Shipped</option> <option value="3">Open & Shipped</option> </select> </label></td> <th width="25%"> </td> <th width="25%"> </td> </tr> </table> NoVal1.php File:<table width="100%" border="0" cellspacing="2" cellpadding="2"> <tr> <th>DO NOT VALIDATE<br> STICKEY:</td> <th width="25%"> </td> <th width="25%"> </td> </tr> </table> I appreciate your help.Thanks Quote Link to comment https://forums.phpfreaks.com/topic/282743-parse-error-syntax-error-unexpected/#findComment-1452738 Share on other sites More sharing options...
cyberRobot Posted October 6, 2013 Share Posted October 6, 2013 Are we still talking about a parse error...or is this a new question? Also, please surround your code blocks with tags. It makes the post (and code) easier to read. Quote Link to comment https://forums.phpfreaks.com/topic/282743-parse-error-syntax-error-unexpected/#findComment-1452750 Share on other sites More sharing options...
Nsm Posted October 6, 2013 Author Share Posted October 6, 2013 When option 1 , 2, 3 or 4 in the following dropdownlist: <label> <select name="select" id="select" onChange="getCat(this.value)"> <option value="" selected="selected">Select Sales District</option> <option value="1">IN05</option> <option value="2">IN02</option> <option value="3">IN23</option> <option value="4">IN13</option> <option value="5">EDU</option> <option value="6">EPP</option> </select></label> Quote Link to comment https://forums.phpfreaks.com/topic/282743-parse-error-syntax-error-unexpected/#findComment-1452776 Share on other sites More sharing options...
Nsm Posted October 6, 2013 Author Share Posted October 6, 2013 is selected I want it to display: OrderStatus.php File: <table width="100%" border="0" cellspacing="2" cellpadding="2"> <tr> <th width="10%" align="left" valign="middle"><strong>ORDER STATUS</strong></td> <th width="10%" align="left" valign="middle"><label> <select name="select" id="select"> <option value="" selected="selected">Select Order Status</option> <option value="1">Open</option> <option value="2">Shipped</option> <option value="3">Open & Shipped</option> </select> </label></td> <th width="25%"> </td> <th width="25%"> </td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/282743-parse-error-syntax-error-unexpected/#findComment-1452777 Share on other sites More sharing options...
Nsm Posted October 6, 2013 Author Share Posted October 6, 2013 When option 5 or 6 is selected i want it to display:NoVal1.php File: <table width="100%" border="0" cellspacing="2" cellpadding="2"><tr><th>DO NOT VALIDATE<br> STICKEY:</td><th width="25%"> </td><th width="25%"> </td></tr></table>[/code ] Quote Link to comment https://forums.phpfreaks.com/topic/282743-parse-error-syntax-error-unexpected/#findComment-1452778 Share on other sites More sharing options...
Nsm Posted October 6, 2013 Author Share Posted October 6, 2013 The way the code is now it does not display anything no matter what is selected.It seems like the code misses something. I see the loading image for a second but nothing is displayed.What am i doing wrong?Thanks Quote Link to comment https://forums.phpfreaks.com/topic/282743-parse-error-syntax-error-unexpected/#findComment-1452779 Share on other sites More sharing options...
Solution Ch0cu3r Posted October 6, 2013 Solution Share Posted October 6, 2013 (edited) Couldn't you posted the above 4 posts into one post? But anyway you're using the wrong logical operator in dynamic-form.php <?php $cat=$_REQUEST['cate']; if($cat==1 && $cat==2 && $cat==3 && $cat==4) { require_once('OrderStatus.php'); } elseif ($cat==5 && $cat==6) { require_once('NoVal1.php'); } ?> The && (and operator) should be changed to the || (or operator). Edited October 6, 2013 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/282743-parse-error-syntax-error-unexpected/#findComment-1452781 Share on other sites More sharing options...
Nsm Posted October 6, 2013 Author Share Posted October 6, 2013 Thanks Ch0cu3r,That did the trick.I did try to post the above in one post but after typing all it only posted the first part. In order not do keep doing it over i posted it again in 4 parts. sorry for the inconvenience and thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/282743-parse-error-syntax-error-unexpected/#findComment-1452782 Share on other sites More sharing options...
jcbones Posted October 6, 2013 Share Posted October 6, 2013 You must be using Chromium. This forum hates Chromium. Once you post a BBCode, it won't post anything else. Quote Link to comment https://forums.phpfreaks.com/topic/282743-parse-error-syntax-error-unexpected/#findComment-1452795 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.