PHP - Unexpected T_if - Please Help
I have written an IF statement:
Code: [Select] $Townsearch = "" if ($Townsearch != "") { $Townsearch = $_REQUEST['rsTown']; list($Town, $County) = split('[,]', $Townsearch); } and I get the error: Parse error: syntax error, unexpected T_IF in D:\retroandvintage.co.uk\wwwroot\main.php on line 7 Similar TutorialsI'm getting a unexpected t_if error and not sure where my fix is. Code: [Select] <?php if($templateVar == '') { $templateVar = 'peach'; //defaulting to be safe } else { $templateVar = $templateVar; //passed from controller } ?> <?php $this->load->view($templateVar . '/header'); ?> <?php $this->load->view($templateVar . '/navigation'); ?> <!-- End Navigation --> <?php $this->load->view($templateVar . '/msgbox'); ?> <?php if((empty($bodyType))||(!isset($bodyType))||(trim($bodyType)=="")){$this->load->view($templateVar . '/body_full');} elseif($bodyType == "full"){$this->load->view($templateVar . '/body_full');} /* Commented out for now, as currently we only have one layout dimension, this is $ out various sections that have different layouts, 2 columns, 3 columns, columns$ on and so forth. elseif($bodyType == "2column"){$this->load->view($templateVar . '/body_2column$ elseif($bodyType == "3column"){$this->load->view($templateVar . '/body_3column$ elseif($bodyType == "blog"){$this->load->view($templateVar . '/body_blog');} */ else{$this->load->view($templateVar . '/body_full');} ?> <?php $this->load->view($templateVar . '/footer'); ?> Issue line: Code: [Select] if((empty($bodyType))||(!isset($bodyType))||(trim($bodyType)=="")){$this->load->view($templateVar . '/body_full');} Hello everyone I'm modifying an open source software called phpScheduleIt, I'm trying to change the machid function based on the $type variable and I'm getting this error below: Parse error: syntax error, unexpected T_IF, expecting T_FUNCTION in C:\xampp\htdocs\phpScheduleIt\lib\Reservation.class.php on line 1122 Code: [Select] 1122 if ($type == RES_TYPE_ADD) 1123 function get_machid() { 1124 return $this->resource->get_property('machid'); 1125 } 1126 if ($type == RES_TYPE_MODIFY) 1127 function get_machid() { 1128 return $this->machid; 1129 } I don't understand why this isn't working :\ phpSchedule it is a really great free open source scheduling software if anyone is interested, full credits to Nick Korbel. http://php.brickhost.com I just started coding in PHP and need helping finding the exact location of the parse error. The output tells me: "Parse error: syntax error, unexpected T_IF in ... on line 8" I know it's not an exact location, but still can't find the syntax mistake. <?php #Script6 - register.php require_once('template/config.inc'); $page_title = 'Register; include ('template/header.html') if (isset($_POST['submitted'])) { require_once ('mysql_connect.php'); //First Name if (eregi ("^[[:alpha:].' -]{2,15}$", stripslashes(trim($_POST['first_name'])))) { $fn = escape_data($_POST['first_name']); } else { $fn = FALSE; echo '<p>Please enter your first name</p>'; } //Last Name if (eregi ("^[[:alpha:].' -]{2,30}$", stripslashes(trim($_POST['last_name'])))) { $ln = escape_data($_POST['last_name']); } else { $ln = FALSE; echo '<p>Please enter your last name</p>'; } //Email Address if (eregi ("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$", stripslashes(trim($_POST['email'])))) { $e = escape_data($_POST['email']); } else { $e = FALSE; echo '<p>Please enter your email address</p>'; } //Username if (eregi ("^[[:alnum:]_]{4,20}$", stripslashes(trim($_POST['username'])))) { $u = escape_data($_POST['username']); } else { $u = FALSE; echo '<p>Please enter a valid username</p>'; } //Password if (eregi ("^[[:alnum:]]{8,20}$", stripslashes(trim($_POST['password1'])))) { if ($_POST['password1'] == $POST['password2']) { $p = escape_data($_POST['password1']); } else { $p = FALSE; echo '<p>Your password did not match the confirmed password</p>'; } } else { $p = FALSE; echo '<p>Please enter a valid password</p>'; } //EVERYTHING if ($fn && $ln && $e && $u && $p) { //Username availability $query = "SELECT user_id FROM users WHERE username='$u'"; $result = @mysql_query ($query); if (mysql_num_rows($result) == 0) { //Add user to DB $query = "INSERT INTO users (username, first_name, last_name, email, password, registration_date) VALUES ('$u', '$fn', '$ln', '$e', PASSWORD('$p'), NOW() )"; $result = @mysql_query ($query); if ($result){ //Email New User $body = "Dear '{$_POST['first_name']}',\n Thank you for registering"; mail ($_POST['email'], 'Thank you for registering', $body, 'From: someemail@domain.com'); //Output echo 'Thank you for registering'; include ('template/footer.html'); exit (); } else { echo '<p>You could not be registered due to a system error. We apologize for the inconvenience</p>'; } } else { echo '<p>That username is already taken. Please choose another.</p>'; } mysql_close(); } else { //if one of the data tests fail echo '<p>Please try again.</p>'; } } ?> <h1>Register</h1> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <fieldset> <p>First Name: <input type="text" name="first_name" value="<?php if (isset($_POST['first_name'])) echo $_POST['first_name']; ?>" /></p> <p>Last Name: <input type="text" name="last_name" value="<?php if (isset($_POST['last_name'])) echo $_POST['last_name']; ?>" /></p> <p>Email Address: <input type="text" name="email" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /></p> <p>User Name: <input type="text" name="username" value="<?php if (isset($_POST['username'])) echo $_POST['first_name']; ?>" /><span>Use only letters, numbers, and underscore. Must be between 4 and 20 characters long.</span></p> <p>Password: <input type="password" name="password1" /><span>Use only letters and numbers. Must be between 8 and 20 characters long.</span></p> <p>Confirm Password: <input type="password" name="password2" /></p> </fieldset> <div align="center"><input type="submit" name="submit" value="Register" /> </div> </form> <?php include_once('template/footer.html'); ?> I just enabled error reporting and I am not that familiar with it. I know I have an error some where around line 33. I know I am missing a bracket or a comma or some other syntax error I just cannot find where the error is. Below is my script. Thanks for any help. Code: [Select] <!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> <title>Airline Survey</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <meta name="author" content="Revised by abc1234"/> </head> <body> <?php $WaitTime = addslashes($_POST["wait_time"]); $Friendliness = addslashes($_POST["friendliness"]); $Space = addslashes($_POST["space"]); $Comfort = addslashes($_POST["comfort"]); $Cleanliness = addslashes($_POST["cleanliness"]); $Noise = addslashes($_POST["noise"]); if (empty($WaitTime) || empty($Friendliness) || empty($Space) || empty($Comfort) || empty($Cleanliness) || empty($Noise)) echo "<hr /><p>You must enter a value in each field. Click your browser's Back button to return to the form.</p><hr />"; else { $Entry = $WaitTime . "\n"; $Entry .= $Friendliness . "\n"; $Entry .= $Space . "\n"; $Entry .= $Comfort . "\n"; $Entry .= $Cleanliness . "\n"; $Entry .= $Noise . "\n"; $SurveyFile = fopen("survey.txt", "w") } if (flock($SurveyFile, LOCK_EX)) { if (fwrite($SurveyFile, $Entry) > 0) { echo "<p>The entry has been successfully added.</p>"; flock($SurveyFile, LOCK_UN; fclose($SurveyFile); else echo "<p>The entry could not be saved!</p>"; } else echo "<p>The entry could not be saved!</p>"; } ?d> <p><a href="AirlineSurvey.html">Return to Airline Survey</a></p> </body> </html> This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=344105.0 Parse error: syntax error, unexpected T_IF in C:\xampp\htdocs\admin\updates_details.php on line 278 while ($data = mysqli_fetch_array($r, MYSQLI_ASSOC)) { echo '<table width="100%" border="1" cellpadding="5" cellspacing="5"> <tr> <td width="11%"><strong>Download</strong></td> <td width="34%"><strong>Update By: ' . $data['update_by'] . '</strong></td> <td width="48%"><strong>Date Created:</strong> ' . $data['dr'] . '</td> <td width="7%"><a href="delete.php?item=update&id=' . $data['update_id'] . '"><img src="../images/delete-icon.png" width="24" height="24" alt="delete" /></a></td> </tr> <tr> <td colspan="4">File: ' . if($data['file'] == 'Yes'){ $data['file']; } . 'Click Here to Download</td> </tr> <tr> <td colspan="4"><p>' . $data['update_msg'] . '</p></td> </tr> </table>'; } // End of WHILE loop. Hi First of all, I know VERY little about PHP, The effort below is a wile guess that has gone wrong. I get this error Parse error: syntax error, unexpected T_IF in /home/repairyo/public_html/shop/includes/content/viewOrders.inc.php on line 57 I have no idea what ive done wrong, may be I am stupid for attempting it. Cheers Paul This is the original code Code: [Select] $view_orders->assign('VAL_STATE',$lang['glob']['orderState_'.$orders[$i]['status']]); This is the modified code Code: [Select] $view_orders->assign('VAL_STATE',$state = $results[$i]['status'] if ($state == '1') { "<font color='#ff9900'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>"; } else if ($state == '2') { "<font color='#009900'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>"; } else if ($state == '4') { "<font color='#cc0000'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>"; } else if ($state == '5') { "<font color='#cc0000'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>"; } else if ($state == '6') { "<font color='#cc0000'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>"; } else if ($state == '7') { "<font color='#ff9900'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>"; } else { $lang['glob']['orderState_'.$orders[$i]['status']]); } Hello, I am struggling here with a T_IF error. The IF Statement is inside a WHILE Loop and I have been searching for the dreaded missing ;'s that normally make these errors. Please help. The error line is in RED Here's the code: while ( $row = mysql_fetch_array($result) ) { echo("<table width='750' height='165' border='0' bgcolor='#DDDEFF' align='center'> <tr> <td width='107' height='30' align='center' bgcolor='#B73230'><b><font size='2' face='Arial, Helvetica, sans-serif' color='FFFFFF'>" . $row["name"] . "<br>ID: " . $row["L_ID"] . "</font></b></td> <td colspan='7' bgcolor='#2B2FE3' align='center'><img src='images/arrows.jpg'></td> </tr> <tr><td rowspan='4' valign='top'><div align=center><img src=images/avatar/".$row["L_ID"] ."s.jpg></div></td> <td width='10' rowspan='3'> </td> <td width='43' height='30'><b>Event: </b></td> <td width='100'><font size='2' face='Arial, Helvetica, sans-serif'>" . $row["title"] . "</font></td> <td width='10' rowspan='3'> </td> <td align='right'><b>Location: </b></td> <td width='160'><font size='2' face='Arial, Helvetica, sans-serif'>" . $row["location"] . "</font></td> <td width='170' align='center'><img src='images/titleAttendingEvents.jpg'></td> </tr> <td align='right' height='30'><b>Date: </b></td> <td><font size='2' face='Arial, Helvetica, sans-serif'>" . date('d/m/Y', strtotime($row['event_date'])) ."</font></td> <td align='right'><b>Post Code: </b></td> <td><font size='2' face='Arial, Helvetica, sans-serif'>" . $row["postCode"] . "</font></td> <td width='170' align='center'><font size='4'>" . $row["attend"] . "</font></td> </tr> <tr> <td align='right' height='30'><b>Time: </b></td> <td height='30'><font size='2' face='Arial, Helvetica, sans-serif'>" . $row["time"] . "</font></td> <td align='right'><form name='email_host' method='post' action='email_host.php'><input type='hidden' name='id' value='" . $row["L_ID"] . "'><input type='hidden' name='title' value='" . $row["title"] . "'><input type='image' src='images/icons/email_s.jpg' align='absmiddle' height='30' alt='Email Host'><b><font size='2' face='Arial, Helvetica, sans-serif'> Email </b></font></form></td> <td align='center'><form name='attending' method='post' action='attend_send.php'><input type='hidden' name='id' value='" . $row["id"] . "'><input type='submit' name='attend_event' value='Attend Event'></form></td> <td width='170' align='center'><img src='images/icons_group.jpg'></td> </tr> <tr>" if ($row['cancel'] == 1) { echo "<td colspan='4' height='30' align='center'><font size='3' face='Arial, Helvetica, sans-serif' color='red'><b>CANCELLED</b></font</td>"; } else { echo "<td colspan='4' height='30'> </td>"; } echo " <td align='center' height='30'><form name='myForm' method='post' action='event_details.php'><input type='hidden' name='event_id' value='" . $row["id"] . "'><input type='image' src='images/btn_event_details.jpg' align='absmiddle' height='30' alt='View Full Event Details'></form></td> </tr> </table> <br>"); } Am I blind? I don't see the problem with this code. It says: Parse error: syntax error, unexpected '}' in /data/21/2/40/160/2040975/user/2235577/htdocs/edit_user1.php on line 35 Code: [Select] <html> <body> <?php if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) ) { $id = $_GET['id']; } elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) ) { $id = $_POST['id']; } else { echo 'you have reached this page in error. no variable passed'; exit(); } // that was the part to check for passed variables. This is what does something with it require ('databaseconnect.php'); if (isset($_POST['submitted'])) { $errors = array(); } if (empty($_POST['scientific name'])) { $errors[] = 'you did not enter a scientific name' } else { $sn = escape_data($_POST['scientific_name']); } // now the common name if (empty($_POST['common_name_english'])) { $errors[] = 'you did not enter a common name' } else { $cn = escape_data($_POST['scientific_name_english']); } // now make changes if (empty($errors)) { $query = "UPDATE table SET plant_name='$id', scientific_name='$sn', common_name_english='$cn' WHERE plant_name=$id"; $result = $mysql_query ($query); if (mysql_affected_row() == 1) { echo 'edit a plant<br> The plant has edited' } else { echo 'system error<br> the plant could not be edited due to a system error.'; echo mysql_error() . 'query:' . $query ; exit(); } } else { echo 'error<br> something already insystem or did not work.'; } } else { echo 'error<br>'; foreach ($errors as $msg) { echo " - $msg<br>"; } echo ' please try again'; } // end of if } // endo of submit condition // always show form $query = "SELECT scientific_name, Common_name_english FROM table WHERE plant_name=$id"; $result = $mysql_query ($query); if(mysql_num_rows($result) == 1) { $row mysql fetch_array ($result); echo 'edit a user' <form action="edit_user1.php" method="post"> scientific name: <input type="text" name="scientific_name" size="45" value="' . $row[scientific_name] . '"><br> common name: <input type="text" name="common_name_english" size="45" value="' . $row[common_name_english] . '"><br> <input type="submit" name="submit" value="submit" /><br> <input type="hidden" name="submitted" value="TRUE" /> <input type="hidden" name="id" value="' . $id . '"/> </form>'; } else { echo 'page error'; } mysql_close(); </body> </html> hello i keep getting an error Parse error: syntax error, unexpected $end in /home/cookbook/public_html/cookbook.php on line 144 can someplease explain it to me? here is the code [list type=decimal] [li][/li] [li][/li] [/list]<?php //include("include/session.php"); @session_start(); // Start_session, check if user is logged in or not, and connect to the database all in one included file include_once("scripts/checkuserlog.php"); // Include the class files for auto making links out of full URLs and for Time Ago date formatting include_once("wi_class_files/autoMakeLinks.php"); include_once ("wi_class_files/agoTimeFormat.php"); // Create the two objects before we can use them below in this script $activeLinkObject = new autoActiveLink; $myObject = new convertToAgo; ?> <?php // Include this script for random member display on home page include_once "scripts/homePage_randomMembers.php"; ?> <?php $sql_blabs = mysql_query("SELECT id, mem_id, the_blab, blab_date FROM blabbing ORDER BY blab_date DESC LIMIT 30"); $blabberDisplayList = ""; // Initialize the variable here while($row = mysql_fetch_array($sql_blabs)){ $blabid = $row["id"]; $uid = $row["mem_id"]; $the_blab = $row["the_blab"]; $notokinarray = array("fag", "gay", "shit", "fuck", "stupid", "idiot", "asshole", "cunt", "douche"); $okinarray = array("sorcerer", "grey", "shug", "farg", "smart", "awesome guy", "asshole", "cake", "dude"); $the_blab = str_replace($notokinarray, $okinarray, $the_blab); $the_blab = ($activeLinkObject -> makeActiveLink($the_blab)); $blab_date = $row["blab_date"]; $convertedTime = ($myObject -> convert_datetime($blab_date)); $whenBlab = ($myObject -> makeAgo($convertedTime)); //$blab_date = strftime("%b %d, %Y %I:%M:%S %p", strtotime($blab_date)); // Inner sql query $sql_mem_data = mysql_query("SELECT id, username, firstname, lastname FROM myMembers WHERE id='$uid' LIMIT 1"); //die($sql_mem_data); while($row = mysql_fetch_array($sql_mem_data)){ $uid = $row["id"]; $username = $row["username"]; $firstname = $row["firstname"]; if ($firstname != "") {$username = $firstname; } // (I added usernames late in my system, this line is not needed for you) /////// Mechanism to Display Pic. See if they have uploaded a pic or not ////////////////////////// $ucheck_pic = "members/$uid/image01.jpg"; $udefault_pic = "members/0/image01.jpg"; if (file_exists($ucheck_pic)) { $blabber_pic = '<div style="overflow:hidden; width:40px; height:40px;"><img src="' . $ucheck_pic . '" width="40px" border="0" /></div>'; // forces picture to be 100px wide and no more } else { $blabber_pic = "<img src=\"$udefault_pic\" width=\"40px\" height=\"40px\" border=\"0\" />"; // forces default picture to be 100px wide and no more } $blabberDisplayList .= ' <table width="100%" align="center" cellpadding="4" bgcolor="#CCCCCC"> <tr> <td width="7%" bgcolor="#FFFFFF" valign="top"><a href="profile.php?id=' . $uid . '">' . $blabber_pic . '</a> </td> <td width="93%" bgcolor="#EFEFEF" style="line-height:1.5em;" valign="top"><span class="greenColor textsize10">' . $whenBlab . ' <a href="profile.php?id=' . $uid . '">' . $username . '</a> said: </span><br /> ' . $the_blab . '</td> </tr> </table>'; } } ?> <!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=ISO-8859-1" /> <meta name="Description" content="Web Intersect is a deft combination of powerful free open source software for social networking, mixed with insider guidance and tutorials as to how it is made at its core for maximum adaptability. The goal is to give you a free website system that has a network or community integrated into it to allow people to join and interact with your website when you have the need." /> <meta name="Keywords" content="web intersect, how to build community, build social network, how to build website, learn free online, php and mysql, internet crossroads, directory, friend, business, update, profile, connect, all, website, blog, social network, connecting people, youtube, myspace, facebook, twitter, dynamic, portal, community, technical, expert, professional, personal, find, school, build, join, combine, marketing, optimization, spider, search, engine, seo, script" /> <title>CookBookers</title> <link href="style/main.css" rel="stylesheet" type="text/css" /> <link rel="icon" href="favicon.ico" type="image/x-icon" /> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <script src="js/jquery-1.4.2.js" type="text/javascript"></script> <style type="text/css"> #Layer1 { height:210px; background-image: url(images/top_container_bg_recipes_new.gif); } body { background-color: #3c60a4; } </style> </head> <body> <?php include_once "header_template.php"; ?> <center> <table cellpadding="0px" cellspacing="0px" style="border:0px solid #666666;" width="950"> <tr> <td> <table width="95%" height="22" border="0" align="center" cellpadding="10" cellspacing="0" style="background-color:#F2F2F2; border:0px solid #666666;"> <tr> <td style="padding-left:45px;"> <?php //die($_SESSION['username']); $qryUsers = "SELECT * from recipies WHERE user='".$_SESSION['username']."'"; //die($qryUsers); $rsUsers = @mysql_query($qryUsers) or die(mysql_error()); ?> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="16%"><h3>All Recipies of </h3></td> <td width="84%"><h3><?php print $_SESSION['username']; ?></h3></td> </tr> <tr> <td> </td> <td> </td> </tr> </table> <?php while($rowUsers = @mysql_fetch_object($rsUsers)) { ?> <?php print"<h3>Public Recipes</h3><br>"; $qryUsers = "SELECT * from recipies WHERE user='".$_SESSION['username']."'"; print"<ol>"; $rsUsers = @mysql_query($qryUsers) or die(mysql_error()); if( @mysql_num_rows($rsUsers)>0 ) { while($rowUsers = @mysql_fetch_object($rsUsers) ) { print "<li style='margin:5px 0px;'><a href=description.php?Rid=".$rowUsers->Rid.">".$rowUsers->title."</a></li>"; } } print"</ol>"; ?> </td> </tr> </table> </td> </tr> <tr> </td> </tr> </table> </center> <?php include_once "footer_template.php"; ?> </body> </html> I know this is probably a missing curly bracket or some other syntax, but I can't seem to spot it, anyone see it? i get this error btw. Parse error: syntax error, unexpected $end in C:\Program Files\xampp\htdocs\cameo\login.php on line 39 <?php session_start(); //sql variables $server = "localhost"; $user = "root"; $pass = ""; $db = "cameo"; //iff user isn't logged in, try to log them in if(!isset($_SESSION['username'])){ if(isset($_POST['submit'])){ //connect to database $dbc = mysqli_connect($server, $user, $pass, $db); //grab entered form data $user_username = mysqli_real_escape_string($dbc, trim($_POST['username'])); $user_password = mysqli_real_escape_string($dbc, trim($_POST['username'])); //if both username and password are entered then find a match in the database if((!empty($user_username)) && (!empty($user_password))) { //look up the username and password in the database $query = "SELECT username FROM cameo WHERE username = '$user_username' AND '$user_password'"; $data = mysqli_query($dbc, $query); //authenticate if data matches a row if(mysqli_num_rows($data) == 1){ //login is okay $row = mysqli_fetch_array($data); $_SESSION['username'] = $row['username']; $_SESSION['is_admin'] = $row['is_admin']; header('Location:index.php'); } else { //username and password are incorrect or missing, so send a message $error_msg = 'Sorry, you must enter a valid username and password to log in.'; } } } ?> Just trying to do a basic query... not working and don't know why: here is inserts.php: <?php $username="wormste1_barry"; $password="barry"; $database="wormste1_barry"; $CarName=$_POST['CarName']; $CarTitle=$_POST['CarTitle']; $CarPrice=$_POST['CarPrice']; $CarMiles=$_POST['CarMiles']; $CarDescription=$_POST['CarDescription']; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO tablename VALUES ('','$CarName','$CarTitle','$CarPrice','$CarMiles','$CarDescription'); mysql_query($query); mysql_close(); ?> That parses the simple form of : form.html: <HTML> <HEAD> </HEAD> <BODY> <form action="inserts.php" method="post"> car Name: <input type="text" name="CarName"><br> Car Title: <input type="text" name="CarTitle"><br> Car Price: <input type="text" name="CarPrice"><br> Car Miles: <input type="text" name="CarMiles"><br> Car Description: <input type="text" name="CarDescription"><br> <input type="Submit"> </form> </BODY> </HTML> I get the error: Parse error: syntax error, unexpected $end in /home/wormste1/public_html/tilburywebdesign/shop/FTPServers/barryottley/showroom/inserts.php on line 23 Don't know whats wrong? Hi, could someone please tell me why I'm getting unexpected $end error in the following code? <?php function documentType(){ echo <<<HEREDOC <?xml version="1.0" encoding="UTF-8"?> <!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> } HEREDOC; ?> Hi, could someone please tell me why I'm getting an unexpected { error in the following code. I have went over it several times and everything seems to be matching. Code: [Select] <?php require_once("functions.php"); ?> <!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>Untitled Document</title> </head> <body> <?php DatabaseConnection(); $query= "SELECT * FROM treats"; $result_set= mysql_query($query); /*if( $result_set = mysql_query($query) ) { while( $products = mysql_fetch_row($result_set) ) { echo $products[0]; echo $products[1]; echo $products[2]; echo $products[3]; echo $products[4]; echo "<img src=\"{$products[5]}\">"; // assuming this is where the image url is } } //print_r(mysql_fetch_row($result_set));*/ $output = "<table>"; while($row = mysql_fetch_array($result)) { $productDetail1['product_id']; $productDetail2['product_title']; $productDetail3['product_Description']; $productDetail4['price']; $productDetail5['product_pic']; $output .= (" <tr> <td>".$productDetail1['product_id'] ."</td> </tr> ") } $output .= "</table>"; ?> </body> </html> What is a T_STRING? google.com cannot find anything about it in the PHP manual. ... and, why am I getting "unexpected T_STRING" for this line? Code: [Select] if ($content['sizes'] == 0) {goto sizem;} else {echo "<B>Small:</B> '.$content['sizes'].'";} I haven't used PHP in a while. I'm getting "unexpected T_ENCAPSED_AND_WHITESPACE" on the second line of this: Code: [Select] if(isset($_GET['name'], $_GET['organization'], $_GET['email'], $_GET['message'])){ mail('memzenator@gmail.com', 'maybearobot: '.$_GET['organization'], "Name: $_GET['name'] /n/n Return Email: $_GET['email'] /n/n $_GET['message']"); } I am getting the syntax error "unexpected T_FOREACH" and I can't see why? I have checked and rechecked but can't find anything wrong with the code. Why am I getting unexpected T_FOREACH? <?php session_start(); $link = mysql_connect('localhost', 'me', '123ok'); mysql_select_db('mydb', $link); $query = "INSERT INTO orders (id, cartcontent) VALUES (null, '". foreach ($_SESSION['cart']['content'] as $content) { $querycontent = "select * from products where id='{$content['id']}'"; $result = mysql_query($querycontent); $row = mysql_fetch_array($result); if ($content['sizes'] == 0) {goto sizel;} else {echo 'Small: "'.$content['sizes'].'"';} sizel: if ($content['sizel'] == 0) {goto endsizes;} else {echo 'Large: "'.$content['sizel'].'"';} endsizes: mysql_query ($querycontent); } ."')"; mysql_query ($query); mysql_close($link); ?> I also tried this, but getting same result. <?php session_start(); $link = mysql_connect('localhost', 'me', '123ok'); mysql_select_db('mydb', $link); $foobar = foreach ($_SESSION['cart']['content'] as $content) { $querycontent = "select * from products where id='{$content['id']}'"; $result = mysql_query($querycontent); $row = mysql_fetch_array($result); if ($content['sizes'] == 0) {goto sizel;} else {echo 'Small: "'.$content['sizes'].'"';} sizel: if ($content['sizel'] == 0) {goto endsizes;} else {echo 'Large: "'.$content['sizel'].'"';} endsizes: mysql_query ($querycontent); } $query = "INSERT INTO orders (id, cartcontent) VALUES (null, '$foobar')"; mysql_query ($query); mysql_close($link); ?> I get parse error unexpected '{' on line 153 (this is last bracket of the code) but all the { brackets are closed. Whats wrong with this code: Code: [Select] function outputModule($moduleID, $moduleName, $sessionData) { if(!count($sessionData)) { return false; } $markTotal = 0; $markGrade = 0; $weightSession = 0; $grade = ""; $sessionsHTML = ''; }; if ($markGrade >70) $grade = 'A'; elseif ($markGrade >=60 && $average <=69) $grade = 'B'; elseif ($markGrade >=50 && $average <=59) $grade = 'C'; foreach($sessionData as $session) { $sessionsHTML .= "<p><strong>Session:</strong> {$session['SessionId']} {$session['Mark']} {$session['SessionWeight']}%</p>\n"; $markTotal += ($session['Mark'] / 100 * $session['SessionWeight']); $weightSession += ($session['SessionWeight']); $markGrade = ($markTotal / $weightSession * 100); } $moduleHTML = "<p><br><strong>Module:</strong> {$moduleID} - {$moduleName} {$markTotal} {$markGrade} {$grade}</p>\n"; return $moduleHTML . $sessionsHTML; } $output = ""; $studentId = false; $courseId = false; $moduleId = false; while ($row = mysql_fetch_array($result)) { if($studentId != $row['StudentUsername']) { //Student has changed $studentId = $row['StudentUsername']; $output .= "<p><strong>Student:</strong> {$row['StudentForename']} {$row['StudentSurname']} ({$row['StudentUsername']})\n"; } if($courseId != $row['CourseId']) { //Course has changed $courseId = $row['CourseId']; $output .= "<br><strong>Course:</strong> {$row['CourseId']} - {$row['CourseName']} <br><strong>Year:</strong> {$row['Year']}</p>\n"; } if($moduleId != $row['ModuleId']) { //Module has changed if(isset($sessionsAry)) //Don't run function for first record { //Get output for last module and sessions $output .= outputModule($moduleId, $moduleName, $sessionsAry); } //Reset sessions data array and Set values for new module $sessionsAry = array(); $moduleId = $row['ModuleId']; $moduleName = $row['ModuleName']; } //Add session data to array for current module $sessionsAry[] = array('SessionId'=>$row['SessionId'], 'Mark'=>$row['Mark'], 'SessionWeight'=>$row['SessionWeight']); } //Get output for last module $output .= outputModule($moduleId, $moduleName, $sessionsAry); //Display the output echo $output; } } |