PHP - Unexpected T_string
I'm getting an unexpected t_string and I'm not sure where on this line I'm missing it.
Code: [Select] <?php echo "<img src=\".base_url()."assets/images/avatar.jpg\".$data->avatar_file."" alt=\"\" />"; ?> Similar TutorialsHi.
I'm trying to use this code:
<?php previous_post_link('%link', '<img src="http://localhost/website.gif" alt="Previous" />' true) ?>But I get the error: Parse error: syntax error, unexpected T_STRING Will this be related to the code incorrect for wordpress or a general error? Thanks 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>"; ?> Any idea why I'm getting this error? Line of code producing error: if( !isset($this->message) OR !isset($this->subject) ){ 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'].'";} Hey all, Relative newbie here. I am trying to create a script that generates a random image (and the associated title) from my mySQL database. The code doesn't seem to be working as the image is blank and the title does not appear either. A new set of eyes may be able to find the problem. Thanks! Code: [Select] <?php include 'open.php'; include 'opendb.php'; $offset_result = mysql_query( " SELECT FLOOR(RAND() * COUNT(*)) AS 'offset' FROM 'recipes' "); $offset_row = mysql_fetch_object( $offset_result ); $offset = $offset_row->offset; $result = mysql_query( " SELECT * FROM 'recipes' LIMIT $offset, 1 " ); print "<table width=\"366\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">"; print "<tr>"; print "<td class=\"recipe_head\">Healthy Lifestyle Gourmet Recipes</td>"; print "<tr>"; print "<td class=\"recipe_title\">{$result['title']}</td>"; print "</tr>"; print "<tr>"; print "<td><image src=\"{$result['image_path'].$result['image_name']}\" height=\"{$result['image_height']}\" width=\"{$result['image_width']}\" /></td>"; print "</tr></table>"; mysql_close(); ?> Got an unexpected T_STRING on line 65: <? // Si estan definidas las variables de las cookies se procede a mostrar el menu pero no sin antes comprobar que los // datos de las cookies verdaderamete son del usuario en cuestion. if(isset($_COOKIE["usNick"]) && isset($_COOKIE["usPass"])) { // Se incluyen los archivos necesarios require('config.php'); require('funciones.php'); // Se sanitizan los datos de las cokies $user=uc($_COOKIE["usNick"]); // Se selecciona la tabla tb_users donde el usuario es el que se provee en la cookie $sql = "SELECT * FROM tb_users WHERE username='$user'"; $result = mysql_query($sql); $row = mysql_fetch_array($result); // Se sanitiza de nuevo la cookie $wask = uc($_COOKIE["usNick"]); // Se define $wesk como el nombre de usuario de la tabla tb_users $wesk = $row['username']; // Se comprueba que el dato de la cookie sea el mismo que el de la tabla, de lo contrario se muestra error, se termina // el script y se borra la cookie. if("$wesk" != "$wask") { echo "Login incorrect."; ?> <input type="button" value="Reload Page" onClick="window.location.reload()"> <? exit(); } // Se sanitiza la cookie usPass $wazk = uc($_COOKIE["usPass"]); // Se define $wezk como el nombre de usuario de la tabla tb_users $wezk = $row['password']; // Se comprueba que el dato de la cookie sea el mismo que el de la tabla, de lo contrario se muestra error, se termina // el script y se borra la cookie. if("$wezk" != "$wazk") { echo "Login incorrect."; ?> <input type="button" value="Reload Page" onClick="window.location.reload()"> <? exit(); } echo" <ul> <li class="m1"><a href="../home.html" class="active">Home</a></li> HERE!!!!!!!!! <li class="m2"><a href="../about-us.html">About</a></li> <li class="m3"><a href="../services.html">Services</a></li> <li class="m4"><a href="../support.html">Support</a></li> <li class="m5"><a href="../contact-us.html">contacts</a></li> <li class="m6"><a href="../sitemap.html">Sitemap</a></li> </ul> "; } else { // funcion para sanitizar variables function limpiare($mensaje) { $mensaje = htmlentities(stripslashes(trim($mensaje))); $mensaje = str_replace("'"," ",$mensaje); $mensaje = str_replace(";"," ",$mensaje); $mensaje = str_replace("$"," ",$mensaje); return $mensaje; } $elref=limpiare($_GET["r"]); echo " <ul> <li class="m1"><a href="../home.html" class="active">Home</a></li> <li class="m2"><a href="../about-us.html">About</a></li> <li class="m3"><a href="../services.html">Services</a></li> <li class="m4"><a href="../support.html">Support</a></li> <li class="m5"><a href="../contact-us.html">contacts</a></li> <li class="m6"><a href="../sitemap.html">Sitemap</a></li> </ul> "; } ?> I am in a beginners php class. I am writing a function library right now. I keep getting an unexpected T_STRING error on line 44. Can anyone see an error in any of these lines? function getAirline ($destination) { if ($destination == "Barcelona") return Web Airlines; //This is line 44 elseif ($destination == "Cairo") return PHP Air; elseif ($destination == "Rome") return Air Java; elseif ($destination == "Santiago") return SQL Air; elseif ($destination == "Tokyo") return Object Oriented Airlines; } I have looked really carefully at this code and can't uderstand why i am getting the unexpected T_STRING error: Code: [Select] $qq = "select * from pts where v1 like '$lname%' and user_id = '". $userarray['id'] ."'"; $rr = mysql_query($qq) or die (mysql_error()); In the pts table there is a field called v1 and user_id. Also the value of $lname is often blank but that shouldn't give me an error right? hi i m adding the last field to my query but getting unexpected t_string error $order_detail="insert into detail_table(unique_id,order_id, customer_name, customer_login_id, order_date, product_name, quantity, shipping, price,total_cost,compatibility) values('$unique_id',$order_id,'$username','$log_id','$shop_date','".$row['product_name'] . "' , " . $row['quantity'] . "," . $row['shipping_cost'] . ",". $row['price'] .",". $row['total_cost']. ",". '". $row['compatibility'] . "'. ")"; mysql_query($order_detail); help me remove it vineet When I try to run a program, I am getting an error message. Not sure why and the code that has the error is shown below. Error message is syntax error, unexpected T_STRING setcookies("username","$username",time()+86400); Can't fix it? Code: [Select] <?php include('connect.php'); mysql_query("SELECT itemQty SUM(itemQty) FROM transactions Where itemDescription= 'raffle'") or die mysql_error()); $row = mysql_fetch_array( $result ); echo $row['sum(itemQty)']; ?> Well sorry to bother you guys with this seemingly stupid problem. I have a file hmgc.php from a friend, and I try to modify the codes myself to add some sort of features to my site. Unfortunately, I am unable to proceed because of this error: Quote Parse error: syntax error, unexpected T_STRING in /home7/pkmnhofc/public_html/adoptables/hmgc.php on line 115 The file is attached in this message already, please take a look at it and tell me what exactly was wrong? I tried to add another if-elseif-else statement within an else statement, may this be a problem? Also this is the scripts around line 115 looks like: if($act == "2"){ $query = "SELECT * FROM ".$prefix."user_inventory WHERE item_owner='$loggedinname' and item_name='Old Rod'"; $result = mysql_query($query); $num = mysql_numrows($result); if($num == 0){ $article_title = "Oops it appears that you do not have an Old Rod yet..."; $article_content = "<center><table style='color: #FFFF31; background: Green; width: 400px; border: 1px solid #9BDDFF;'><tr><td> It seems that you do not have an Old Rod in your inventory yet, are you sure it is the best choice for you to fish without a rod?<br><br> To fix this issue, simply go back and take Fishing Quiz. You syhould be able to acquire an Old Rod for yourself if you answer all these questions successfully. Trust me, they aint really hard at all if you know something about pokemon and the fishing mechanism already.<br> <br><a href='fishingquiz.php'>Take the Fishing Quiz now!!!</a> } else{ $randnum1 = rand(1, 500); if($randnum1 >= 1 and $randnum1 < 225){ $article_title = "You got a Magikarp"; $article_content = "<center><table style='color: #b60400; background: black; width: 400px; border: 1px solid #b60400;'><tr><td><br><br> Now is your chance to adopt a wild Magikarp!</td></tr></table></center>"; } else if($randnum1 >= 225 and $randnum1 < 250){ $article_title = "You got a Goldeen"; $article_content = "<center><table style='color: #b60400; background: black; width: 400px; border: 1px solid #b60400;'><tr><td><br><br> Now is your chance to adopt a wild Goldeen</td></tr></table></center>"; } else{ $article_title = "Not even a bite"; $article_content = "<center><table style='color: #b60400; background: black; width: 400px; border: 1px solid #b60400;'><tr><td><br><br> Too bad you got nothing...</td></tr></table></center>"; } } } Thank you so much for reading this thread, I appreciate it a lot. Hi guys, I have got a problem with the parse error. Error: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/mysite/public_html/Protected.php on line 64 The parse error are highlighing in line 64. I found out that the problem are coming from this line: Code: [Select] Protected: '<p id='Protected_Required'>' . $row["Protected_Required"] . '</p>''; here's the current code: Code: [Select] <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'mydbuser'); define('DB_PASSWORD', 'mydbpass'); define('DB_DATABASE', 'mydbname'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean($var){ return mysql_real_escape_string(strip_tags($var)); } $username = clean($_GET['user']); $pass = clean($_GET['pass']); if($username == '' && $pass == ''){ // both are empty $errmsg_arr[] = 'Username and password are missing. You must enter both or the other one.'; $errflag = true; } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; echo implode('<br />',$errmsg_arr); } else { $insert = array(); if(isset($_GET['user'])) { $insert[] = 'username = \'' . clean($_GET['user']) .'\''; } if(isset($_GET['pass'])) { $insert[] = 'pass = \'' . clean($_GET['pass']) . '\''; } if (count($insert)>0) { $names = implode(',',$insert); if($username && $pass) { $query="SELECT id, images, Protected_Required FROM mydatalist WHERE username='$username'"; $result1=mysql_query($query) or die('Error:<br />' . $qry . '<br />' . mysql_error()); while ($row = mysql_fetch_array($result1)) { echo '<a href="http://' . $row["images"] . '">Link</a> </td> | <a href="delete.php?id='.$row['id'].'">Delete</a></td> | Protected: '<p id='Protected_Required'>' . $row["Protected_Required"] . '</p>''; } } } } ?> Do you know how to fix the error I get? Any advice would be much appreciated. Thanks in advance. This is the error.. Code: [Select] Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE or '$' in /htdocs/testing//suggest.php on line 35 ..and this is line 35 in suggest.php... mysql['username'],$mysql['password']);() could you point me in the right direction?. Thanks. edit - oh, and the context of the code is... Code: [Select] mysql_connect($mysql['host'],$ mysql['username'],$mysql['password']); mysql_select_db($mysql['db']); Hi everyone,
I am fairly new to PHP coding, and I am attempting to write a script that reads entries from a contact entry from and adds them to a database. However I keep receiving an error that states:
" Parse error: syntax error, unexpected 'name' (T_STRING), expecting ']' in C:\wamp\www\it665\addContact.php on line 16"
I have been trying to figure out what I am missing, or need to remove, and I am having the hardest time. Below is the entire code for the addContact.php script that I keep receiving this error for. I would really appreciate any feedback.
<?php Can anyone tell me what's wrong with this particular part of my php code? $handle = fopen(''lovell.txt, ''a''); That was the line it said there was an issue with, and I'm new and can't seem to figure it out. Hi Guys I have got a page generating the following error Error:Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/sites/trade-bidz.co.uk/public_html/functions/reg_functions.php on line 3 The offending code is below (I have removed some of the URL due to security. Code: [Select] <?php function getVehData(){ $file="https://www.cdlvis.com/lookup/getxml?username=***********&mode=test&key=*********&vrm=$_POST['veh_reg']"; $dom=new DOMdocument(); $dom->load($file); $xml=simplexml_import_dom($dom); echo('<tr><td>Make<td></td></tr> <tr><td>Model<td></td></tr> <tr><td>Make<td></td></tr> <tr><td>Date of Manufacture<td></td></tr> <tr><td>First Registered<td></td></tr> <tr><td>Colour<td></td></tr> <tr><td>Body<td></td></tr> <tr><td>No. of Doors<td></td></tr> <tr><td>Engine Size (cc)<td></td></tr> <tr><td>Fuel Type<td></td></tr> <tr><td>Gearbox Type<td></td></tr> <tr><td>Previous Owners<td></td></tr> <tr><td>BHP<td></td></tr> <tr><td>Emissions<td></td></tr> </table> '); } ?> |