PHP - Unexpected T_elseif
Syntax error found: unexpected T_ELSEIF on line 23
Code: [Select] <?php require("config.php"); $result = mysql_query("SELECT name, mics, status, date_format(eventStart, '%M %e %Y') as start, date_format(eventFinish, '%M %e %Y') as end FROM events where status='S' or status='A' order BY eventStart"); $sta=$row['status']; { echo "<table rules='rows'> <tr> <th width='50'><font color='yellow' size='1'>MICS</th> <th width='200'><font color='yellow' size='1'>Charity</th> <th width='125'><font color='yellow' size='1'>Start Date</th> <th width='125'><font color='yellow' size='1'>End Date</th> </tr>"; while ($row = mysql_fetch_array($result)) { if ($sta == "A"); { echo "<tr>"; echo "<td><font color='red' size='1'>" . $row['mics'] . "</td>"; echo "<td><font color='red' size='1'>" . $row['name'] . "</td>"; echo "<td><font color='red' size='1'>" . $row['start'] . "</td>"; echo "<td><font color='red' size='1'>" . $row['end'] . "</td>"; echo "</tr>"; } elseif ($sta == "S"); { echo "<tr>"; echo "<td><font color='#ffffff' size='1'>" . $row['mics'] . "</td>"; echo "<td><font color='#ffffff' size='1'>" . $row['name'] . "</td>"; echo "<td><font color='#ffffff' size='1'>" . $row['start'] . "</td>"; echo "<td><font color='#ffffff' size='1'>" . $row['end'] . "</td>"; echo "</tr>"; } } echo "</table>"; } mysql_close($dbh); ?> [code] I don't see it. Thanks Similar Tutorialsif(mysql_num_rows($query) == 1) { $compny = mysql_query("SELECT * FROM company WHERE value='". $comp ."'"); $company = mysql_result($compny, 0); if(mysql_num_rows($company) == 0) { echo "Company not found"; die(); } $getcompstt = mysql_query("SELECT stat FROM company WHERE value='". $comp ."' LIMIT 1"); $getcompstat = mysql_result($getcompstt, 0); elseif($getcompstat == "3") Alright, I have created a hash password checker and here is my code: include("include.php"); // include the mySQL info! $users = mysql_query(" SELECT * FROM User "); // Select all from the users table in the database! while($row = mysql_fetch_array($users)) // While it fetches the users do the following... { if (hash("sha256", $password) == $row["Password"]) echo "Congratulations! The Hash matches the password entered into the database!"; } elseif (hash("sha256", $password) != $row["Password"]) { echo "Your Hash failed to match the password entered!"; } Now for some reason this displays a totally blank page. When I turn error display on I get the error "Unexpected T_ELSEIF" on this line elseif (hash("sha256", $password) != $row["Password"]) Any help is appreciated... hello, i am having a problem in my cron file that runs daily, the code posted below at the last block at the elseif ($chance > 2.5) <b>Parse error</b>: syntax error, unexpected T_ELSEIF in <b>/home/content/run_daily.php</b> on line <b>240</b><br /> ... $db = $dbh->prepare("select star_id from {$game}_stars where event_random = '6'"); $db->execute(); $bh_sys = $db->fetchrow_hashref(); if ($bh_sys) { $chance = rand(5); if ($chance < 1) { mysql_query("update {$game}_stars set event_random = 1, metal = '0', fuel='0', star_name = 'BlackHole' where star_id = '$bh_sys->{star_id}'"); mysql_query("insert into {$game}_news (timestamp, headline, login_id) values (".time().",'The <b>SuperNova Remnant</b> in <b class=b1>system $bh_sys->{star_id}</b> has formed into a <b>blackhole</b>. Being a slow process, all ships managed to get out to system #<b>1</b>. We expect no further trouble from that system. <font color=lime>- - - Science Institute of Sol - - -</font>','-11')"); $db = $dbh->prepare("select location,login_id,ship_id,ship_name from {$game}_ships where location = '$bh_sys->{star_id}'"); $db->execute(); while ($ship_bh = $db->fetchrow_hashref()) { mysql_query("update {$game}_ships set location = '1' where ship_id = '$ship_bh->{ship_id}'"); mysql_query("insert into {$game}_messages (timestamp,sender_name,sender_id, login_id, text) values(".time().",'BlackHole','$ship_bh->{login_id}','$ship_bh->{login_id}','Your ship the <b class=b1>$ship_bh->{ship_name}</b> escaped a blackhole forming from a SuperNova Remnant in system #<b>$ship_bh->{location}</b>. It is now in system #<b>1</b>')"); mysql_query("update {$game}_users set location = '1' where location = '$bh_sys->{star_id}'"); print "\nSN remnant in $bh_sys->{star_id} to blackhole\n"; } elseif ($chance > 2.5) { mysql_query("update {$game}_stars set event_random = '14' where star_id = '$bh_sys->{star_id}'"); mysql_query("insert into {$game}_news (timestamp, headline, login_id) values (".time().",'After much study, we have decided that the star in system <b>$bh_sys->{star_id}</b> will <b class=b1>not</b> become a Blackhole, as it was not massive enough. This system will remain a harmless Super-Nova Remnant, with lots of minerals in. <font color=lime>- - - Science Institute of Sol - - -</font>','-11')"); print "\nSN remnant in $bh_sys->{star_id} safe\n"; } } ... Help I can't figure out the problem with my code. This is the error I am receiving... Parse error: syntax error, unexpected T_ELSEIF in /****/****/****/****/****/**** on line 68 This is my code: ----------------------------------------------------------------------------------------------------- Code: [Select] <? include "./includes/config.inc.php"; include $include_path."countries.inc.php"; #// If user is not logged in redirect to login page if(!isset($_SESSION["BPLowbidAuction_LOGGED_IN"])) { Header("Location: user_login.php"); exit; } if($_POST['action'] == "update") { #// Check data if ($_POST['TPL_email']) { if (strlen($_POST['TPL_password'])<6 && strlen($_POST['TPL_password']) > 0) { $TPL_err=1; $TPL_errmsg=$ERR_011; } else if (strlen($_POST['TPL_email'])<5) { $TPL_err=1; $TPL_errmsg=$ERR_110; } elseif(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$",$_POST['TPL_email'])) { $TPL_err = 1; $TPL_errmsg = $ERR_008; } $nletter=isset($_POST['TPL_nletter']) ? $_POST['TPL_nletter'] :0; $sql="UPDATE BPLA_users SET email=\"". AddSlashes($_POST['TPL_email']) ."\", reg_date=reg_date" ." , nletter=\"". AddSlashes($_POST['TPL_nletter']); if(strlen($_POST['TPL_password']) > 0) { $sql .= "\", password=\"". md5($MD5_PREFIX.AddSlashes($_POST['TPL_password'])); } $sql .= "\" WHERE nick='".$_SESSION['BPLowbidAuction_LOGGED_IN_USERNAME']."'"; $res=mysql_query ($sql); //$query = "select * from BPLA_users where nick='".$_SESSION['BPLowbidAuction_LOGGED_IN_USERNAME']."'"; //$result = @mysql_query($query); //if(!$result) { // MySQLError($query); // exit; //} else { // $USER = mysql_fetch_array($result); // $TPL_nick = $USER['nick']; // $TPL_email = $USER['email'];; // $TPL_nletter = $USER['nletter']; // } //} // #// Redirect user to his/her admin page $TMP_MSG = $MSG_183; $_SESSION["TMP_MSG"]=$TMP_MSG; /*Header("Location: user_menu.php"); exit; include "header.php"; include "templates/template_updated.html"; */ //include "header.php"; //include phpa_include("template_change_details_php.html"); } else { $TPL_err=1; $TPL_errmsg=$ERR_112; elseif(($_POST['action'] != "update" || $TPL_errmsg !=1)) { //#// Retrieve user's data //$query = "select * from BPLA_users where nick='".$_SESSION['BPLowbidAuction_LOGGED_IN_USERNAME']."'"; //$result = @mysql_query($query); //if(!$result) { // MySQLError($query); // exit; //} else { // $USER = mysql_fetch_array($result); // $TPL_nick = $USER['nick']; // $TPL_email = $USER['email']; // $TPL_nletter = $USER['nletter']; //} //echo "111 "; //include "header.php"; //include phpa_include("template_change_details_php.html"); } if($TPL_err==1) { //include "header.php"; //include phpa_include("template_change_details_php.html"); } #// Retrieve user's data $query = "select * from BPLA_users where nick='".$_SESSION['BPLowbidAuction_LOGGED_IN_USERNAME']."'"; $result = @mysql_query($query); if(!$result) { MySQLError($query); exit; } else { $USER = mysql_fetch_array($result); $TPL_nick = $USER['nick']; $TPL_email = $USER['email']; $TPL_nletter = $USER['nletter']; } include "header.php"; include phpa_include("template_change_details_php.html"); include "footer.php"; $TPL_err=0; $TPL_errmsg=""; ?> 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.'; } } } ?> 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> 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> 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; ?> 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> 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? does anyone see why i get an unexpected T_VARIABLE here? Ive varied the code from something i had that was working so i don't see why it fails to work, any help would be great thanks. Code: [Select] <?php require_once('_includes/db_connection.php'); if ($result = mysql_query('SELECT Banned FROM users WHERE username = '$username'')) { if (mysql_num_rows($result)) { $row = mysql_fetch_assoc($result); if ($row['Banned'] != No) { echo "You are banned"; exit; } } } ?> I'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');} <?php //Directorul unde sa caute $director = /Users'; //Un filtru pentru extensie $extensie = 'ini'; //Logare FTP $server_ftp = '93.'; $utilizator_ftp = 'x@yahoo.com'; $parola_ftp = 'x'; $conexiune = ftp_connect($server_ftp); ftp_login($conexiune,$utilizator_ftp,$parola_ftp) or die('Logarea FTP a esuat!'); //Setam pe pasiv ftp_pasv($conexiune,true); //Cream lista $fisiere = array(); $fisiere = raw_list('$director'); //Printam rezultatele $i=0; $count=count($fisiere); while($i < $count); print ''.$fisiere[$id].''; $i++; ftp_close($conexiune); endwhile; //Functia raw_list function raw_list($folder) { Global $conexiune; Global $extensie; Global $fisiere; $exntesii = explode(",", $extensie); $list = ftp_rawlist($conexiune, $folder); $anzlist = count($list); $i = 0; while ($i < $anzlist): $split = preg_split("/[\s]+/", $list[$i], 9, PREG_SPLIT_NO_EMPTY); $ItemName = $split[8]; $endung = strtolower(substr(strrchr($ItemName,"."),1)); $path = "$folder/$ItemName"; if (substr($list[$i],0,1) === "d" AND substr($ItemName,0,1) != "."): raw_list($path); elseif (substr($ItemName,0,2) != "._" AND in_array($endung,$extensii)): array_push($files, $path); endif; $i++; endwhile; return $files; } ?> Parse error: syntax error, unexpected T_ENDWHILE in xxxxxxx/vs/conturi.php on line 28 Hi, I have a basic php code that allows the user to search and display data from a database. I have searched and searched the entire code for errors, but I cannot find any. When I try to run the code (do a search) it gives me this error: Parse error: syntax error, unexpected T_LNUMBER, expecting ',' or ';' on line 99 This is my line 99: echo ' <a href="'.$_SERVER['PHP_SELF']."?s=$news&q=$var\">Next 10 >></a>"; and this is my whole code: <?php // Get the search variable from URL $var = @$_GET['q'] ; $trimmed = trim($var); //trim whitespace from the stored variable // rows to return $limit=10; // check for an empty string and display a message. if ($trimmed == "") { echo "<p>Please enter a search...</p>"; exit; } // check for a search parameter if (!isset($var)) { echo "<p>We dont seem to have a search parameter!</p>"; exit; } //connect to your database ** EDIT REQUIRED HERE ** mysql_connect("localhost","xxxxxx","xxxxx"); mysql_select_db("xxxxxx") or die("Unable to select database"); // Build SQL Query $query = "SELECT lastname, firstname, state, zip, jobtype, otherjobtype, nightavail, weekendavail, ptft, objective, resume FROM data WHERE jobtype LIKE '%" . $trimmed . "%' ORDER BY lastname"; $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); // If we have no results, offer a google search as an alternative if ($numrows == 0) { echo "<h4>Results</h4>"; echo "<p>Sorry, your search: "" . $trimmed . "" returned zero results</p>"; echo "<p><a href='http://www.google.com/search?q=". $trimmed . "' target='_blank' title='Look up " . $trimmed . " on Google'>Click here</a> to try the search on google</p>"; } // next determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; } // get results $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query"); // display what the person searched for echo "<p>You searched for: "" . $var . ""</p>"; // begin to show results set echo "Results"; $count = 1 + $s ; // now you can display the results returned while ($row= mysql_fetch_array($result)) { $title = $row["1st_field"]; echo "$count.) $title" ; $count++ ; } $currPage = (($s/$limit) + 1); //break before paging echo "<br />"; // next we need to do the links to other results if ($s>=1) { $prevs=($s-$limit); print ' <a href="'.$_SERVER['PHP_SELF'].'?s=$prevs&q=$var"><< Prev 10</a>  '; } // calculate number of pages needing links $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } // check to see if last page if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { // not last page so give NEXT link $news=$s+$limit; echo ' <a href="'.$_SERVER['PHP_SELF']."?s=$news&q=$var\">Next 10 >></a>"; } $a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; echo "<p>Showing results $b to $a of $numrows</p>"; ?> I am completely new to php. If anyone could give me a hint I'd greatly appreciate it... No clue what's wrong, line 9. Code: (php) [Select] <?php require '/opt/lampp/htdocs/PHP/PHP&MYSQL/scripts/database_connection.php'; // database connection file $query_text = $_REQUEST['query']; $result = mysql_query($query_text); if (!$result) { die("Error connecting to database:". $query_text . mysql_error() .); } echo "<p>Results from your query:</p>"; echo "<ul>"; while ($row = mysql_fetch_row($result)) { echo "<li>({$row[0]}</li>"; } echo "</ul>"; ?> Hi, i am getting the following error message, but everything seems ok in script... Parse error: syntax error, unexpected ';' in /www/zxq.net/htdocs/admin/includes/functions.php on line 27 This is the code snippet: function addCat($cName, $cDesc) { $query = mysql_query("INSERT INTO categories VALUES(null,'$cName','$cDesc')") or die(mysql_error()); } This seems like such a simple error, however I've no idea why I am getting it. apparently I have an unexpected comma on line 4 of the code below. I can't work out what the error is. Any ideas? Sorry to be a pain if it really is something simple, but I'm a bit new to all this php stuff. <?php function percentCalc($value1,$value2,$value3,$value4,$value5,$total) { $array=($value1,$value2,$value3,$value4,$value5); while (list($key,$arraycontent)= each($array)) { $c_percent=(($arraycontent/$total)*100); $final_array[]=$c_percent; } return $final_array; } ?> 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 |