PHP - Echo Syntax Problem. Please Help.
ok im building facebook app and im just back to php after months not touched it.
this is the code: $image = $facebook->api_client->photos_get(null,null, echo $uid); print_r ($image); echo "<BR>"; echo $image[0]["src"]; the problem is that echo $uid i tried every variation and it does not work! i maybe forget something that i should have done? the $uid containing user id numbers so what i did wrong and if im not wrong i wanted the numbers($uid) Wrapped in quotation marks so i tried: echo ." $uid ". and alot of other please help tnx Similar TutorialsI can't figure out how to write the a href part to make it blend in with the existing img syntax. How do I alter this? Code: [Select] <?php echo '<a href=\"{$r['feedusername']\"><img src="', getUserAvatar($r['feedusername']), "\" class=\"avatar mediumsmall newspadding f_left mrl\" title=\"${r['associate_name']}\" alt=\"${r['associate_name']}\" /></a>"; ?> Hi.. I create mysql syntax for query testing before i input to my php code here is my mysql code: Code: [Select] set @t = 0; set @rqty=31968; SELECT LOT_CODE as code, DATE_ENTRY, CASE WHEN @t+OUTPUT_QTY > @rqty THEN @rqty -@t ELSE OUTPUT_QTY END as qty, @t := @t + d.OUTPUT_QTY as cumulative FROM dipping d WHERE SUBSTR(LOT_CODE, 9,4) = 'P28' AND (@t < @rqty); and i attach the sample output of the above query. Now that query test is work i will input that code to my php codes. $sql = "SELECT SKUCode, Materials, Comp, Qty FROM bom WHERE SKUCode = '$SKUCode'"; $res = mysql_query($sql, $con); ($row = mysql_fetch_assoc($res)); $Materials = $row['Materials']; $Qty = $row['Qty']; $Comp = $row['Comp']; //P28 //-----Compute Req Qty and Save to table---// $ReqQty = $Qty * $POReq; // 31968 $sql = "UPDATE bom SET ReqQty = '$ReqQty' WHERE SKUCode = '$SKUCode' AND Materials = '$Materials'"; $resReqQty = mysql_query($sql, $con); $t = 0; $sql = "SELECT LOT_CODE as code, DATE_ENTRY, CASE WHEN $t+OUTPUT_QTY > $ReqQty THEN $ReqQty -$t ELSE OUTPUT_QTY END as qty, $t := $t + d.OUTPUT_QTY as cumulative FROM dipping d WHERE SUBSTR(LOT_CODE, 9,4) = '$Comp' AND ($t < $ReqQty)"; when I echo the query: I got this: SELECT LOT_CODE as code, DATE_ENTRY, CASE WHEN 0+OUTPUT_QTY > 31968 THEN 31968 -0 ELSE OUTPUT_QTY END as qty, 0 := 0 + d.OUTPUT_QTY as cumulative FROM dipping d WHERE SUBSTR(LOT_CODE, 9,4) = 'P28' AND (0 < 31968) then I run it to the sql and I got an error: Error Code : 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':= 0 + d.OUTPUT_QTY as cumulative FROM dipping d WHERE SUBSTR(LOT_CODE, 9,4) = '' at line 1 (0 ms taken) Any help is highly appreciated Thank you so much Hi all, I have this problem with an echo I have this code, what is working only not all of it, it request a database (ID) TID which is a catorgy. Now I need to TID to be in a place but can't to seem to get it. Here is the code: Code: [Select] <?php defined('_JEXEC') or die('Restricted access'); // no direct access ?> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"> </script> <script type="text/javascript"> /* function changeActiveCategory(id,show) { var a_categoryname = "a_category"+id; if(show){ document.getElementById(a_categoryname).className = "active"+id; }else{ document.getElementById(a_categoryname).className = ""; } } */ function changeActiveType(id,show) { var a_typename = "a_type"+id; if(show){ document.getElementById(a_typename).className = "active"+id; }else{ document.getElementById(a_typename).className = ""; } } var markerGroups = { "1": [], "2": [], "3": [], "4": [], "5": []}; function toggleGroup(type) { for (var i = 0; i < markerGroups[type].length; i++) { var marker = markerGroups[type][i]; if (marker.getVisible()) { marker.setVisible(false); changeActiveType(type,false); } else { marker.setVisible(true); changeActiveType(type,true); } } } function changeActiveButton(id) { document.getElementById("idmap").className = "map"; document.getElementById("idsatellite").className = "satellite"; document.getElementById("idterrain").className = "terrain"; var dividname = "id"+id; document.getElementById(dividname).className = id+" "+id+"active"; } var map; var goHome = new google.maps.LatLng(<?php echo $DefaultLat;?>, <?php echo $DefaultLng;?>); function HomeControl(controlDiv, map) { controlDiv.style.padding = '0px 5px'; var controlUI = document.createElement('DIV'); controlUI.style.cursor = 'pointer'; controlUI.setAttribute("class","mapType"); controlDiv.appendChild(controlUI); var controlMap = document.createElement('DIV'); if(map.getMapTypeId()=='roadmap'){ controlMap.setAttribute("class","map mapactive"); }else{ controlMap.setAttribute("class","map"); } controlMap.setAttribute("id","idmap"); controlUI.appendChild(controlMap); var controlsatellite = document.createElement('DIV'); if(map.getMapTypeId()=='satellite'){ controlsatellite.setAttribute("class","satellite satelliteactive"); }else{ controlsatellite.setAttribute("class","satellite"); } controlsatellite.setAttribute("id","idsatellite"); controlUI.appendChild(controlsatellite); var controlterrain = document.createElement('DIV'); if(map.getMapTypeId()=='hybrid'){ controlterrain.setAttribute("class","terrain terrainactive"); }else{ controlterrain.setAttribute("class","terrain"); } controlterrain.setAttribute("id","idterrain"); controlUI.appendChild(controlterrain); google.maps.event.addDomListener(controlUI, 'click', function() { /*map.setCenter(goHome);*/ }); google.maps.event.addDomListener(controlMap, 'click', function() { map.setMapTypeId(google.maps.MapTypeId.ROADMAP); changeActiveButton('map'); }); google.maps.event.addDomListener(controlsatellite, 'click', function() { map.setMapTypeId(google.maps.MapTypeId.SATELLITE); changeActiveButton('satellite'); }); google.maps.event.addDomListener(controlterrain, 'click', function() { map.setMapTypeId(google.maps.MapTypeId.HYBRID); changeActiveButton('terrain'); /*map.setMapTypeId(google.maps.MapTypeId.TERRAIN);*/ }); } function initialize() { var latlng = new google.maps.LatLng(<?php echo $DefaultLat;?>, <?php echo $DefaultLng;?>); var myOptions = { zoom: <?php echo $MapDistance;?>, center: latlng, navigationControl:true, scaleControl:true, mapTypeControl: false, mapTypeId: google.maps.MapTypeId.HYBRID }; var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); var homeControlDiv = document.createElement('DIV'); var homeControl = new HomeControl(homeControlDiv, map); homeControlDiv.index = 1; map.controls[google.maps.ControlPosition.RIGHT].push(homeControlDiv); var gmarkers = []; var htmls = []; <?php echo 'var ptooltip=new Array();'; echo 'var showhtml=new Array();'; if($items) { $p=0; foreach ($items as $item) { $link = LinkHelper::getLink('properties','showproperty','',$item->CYslug,$item->Sslug,$item->Lslug,$item->Tslug,$item->Pslug); $item->name=str_replace("'","\'",$item->name); echo "\n"."ptooltip[".$p."]=new Array( '".$item->id."','".$item->ref."','".$item->tid."','".$item->name."','".$link."');"."\n"; /*property details*/ if($item->imagename!=NULL){ $img=$item->imagename;}else{$img='noimage.jpg';} $myHtml=''; $myHtml.='<div id="propertydetail"><div class="title"><a href="'. $link.'" title="'.str_replace('"',' ',$item->name).'">'.$item->name.'</a></div><div class="image"><img src="images/properties/images/thumbs/'.$item->id.'/'.$img.'" alt="'.str_replace('"',' ',$item->name).'" width="100" height="75"></div><div class="text">'; if ($item->name_type) { $myHtml.=JText::_($item->name_type).'<br />'; } if ($item->address) { $myHtml.=JText::_($item->address).'<br />'; } $myHtml.='</div>'; $myHtml.='<div class="property_button">'; $myHtml.='<a class="BottomlnkDetail" href="'.$link.'" title="'.$item->id.'">Lees meer...</a>'; $myHtml.='</div>'; $myHtml.='</div>'; echo "\n"."showhtml[".$p."]='".$myHtml."';"."\n"; $myHtml=''; /*end property details*/ $p++; } } ?> var base_Icon=new Array(); base_Icon = '<?php echo JURI::base();?>modules/mod_prop_googlemap/img/beer.png'; <?php if($items) { $x=0; foreach ($items as $item) { ?> var myLatlng = new google.maps.LatLng(<?php echo $item->lat;?>,<?php echo $item->lng;?>); var marker = new google.maps.Marker({ position: myLatlng, map: map, icon: base_Icon }); /*alert (marker.number);*/ marker.setTitle('Klik voor meer info.'); attachSecretMessage(marker, <?php echo $x;?>); markerGroups[HIER MOET TID KOMEN].push(marker); <?php $x++; } } ?> function attachSecretMessage(marker, number) { var infowindow = new google.maps.InfoWindow( { content: showhtml[number], /* disableAutoPan: true,*/ size: new google.maps.Size(50,50) }); google.maps.event.addListener(marker, 'click', function() { infowindow.open(map,marker); /*showInContentWindow(showhtml[number]);*/ }); google.maps.event.addListener(infowindow, 'closeclick', function() { /*infowindow.close(map,marker); showInContentWindow(''); closeInContentWindow();*/ }); /* google.maps.event.addDomListener(controlterrain, 'click', function() { map.setMapTypeId(google.maps.MapTypeId.HYBRID); changeActiveButton('terrain'); }); */ } function showInContentWindow(text) { var sidediv = document.getElementById('content_window'); sidediv.style.visibility = "visible"; sidediv.innerHTML = text; } function closeInContentWindow() { var sidediv = document.getElementById('content_window'); sidediv.style.visibility = "hidden"; } } </script> <div class="prop_googlemap" style="width:960px; height:510px"> <div class="first"> <div class="second"> <div class="third"> <div id="map_canvas" style="width: 950px; height: 500px"></div> <div id="prop_googlemap_categories_all"> <div id="prop_googlemap_categories"> <ul class="categorys"> <li><a id="a_type1" class="active1" href="javascript:void(0)" onclick="toggleGroup('1');">Kroeg</a></li> <li><a id="a_type2" class="active2" href="javascript:void(0)" onclick="toggleGroup('2');">Discotheek</a></li> <li><a id="a_type3" class="active3" href="javascript:void(0)" onclick="toggleGroup('3');">Zaal</a></li> <li><a id="a_type4" class="active4" href="javascript:void(0)" onclick="toggleGroup('4');">test</a></li> </ul> </div> <div style="clear:both"></div> <div class="prop_googlemap_categories_bottom"></div> </div> <div id="content_window"></div> <div id="side_bar"></div> </div> </div> </div> </div> <script type="text/javascript"> initialize(); </script> <div style="clear:both"></div> As you can see he Code: [Select] markerGroups[THIS IS WHERE THE TID SHOULD COME].push(marker);where now it says: "THIS IS WHERE THE TID SHOULD COME" there needs to be a number ( 1 stands for a bar, 2 stands for a disco, 3 for something else. Now this is where I ask for the TID: Code: [Select] echo "\n"."ptooltip[".$p."]=new Array( '".$item->id."','".$item->ref."','".$item->tid."','".$item->name."','".$link."');"."\n"; But it can be me, but can't seem to get it working.... Can't seem to get the right code for "THIS IS WHERE THE TID SHOULD COME" anyone that could help me? Thanks! Hello, I have this syntax on my header div Code: [Select] <p><a href="javascript:ajaxpage('shopcart.php', 'content');" class="difflink"><img src="../stock_photos/shopcart.png"><?php echo '<span class="text">'.writeShoppingCart().'</span>'; ?></a></p> but whatever I try it always output my echo in the next line instead of next to my picture file. How can I do it displayed at the same line? Thank you This php file cant echo in the 2nd php code, can anyone help me about this? 1st php code to connect into the 2nd php code Code: [Select] <?php $Total = $Total + $Amount; } ?> </tr> <tr> <td colspan="3" align="Right">Total</td> <td align ="Center"><?php echo number_format($Total,2);?></td> </tr> 2nd php code Code: [Select] <?php $db = mysql_connect("localhost", "root", ""); mysql_select_db("vinnex",$db); $TransNo = $_POST['TransNo']; $Username = $_POST['Username']; $Date = $_POST['Date']; $Total = $_GET['Total']; echo $Total; $sqltransaction = " INSERT INTO transaction (TransNo, Username, Date, Total) VALUES ('$TransNo', '$Username', '$Date', '$Total')"; $resulttransaction = mysql_query($sqltransaction); ?> Having problems with my script echo without form being completed yet. Any help would be appreciated. The echo that is outputting early is "You must enter a Session Name". Code: [Select] <html> <head> <title>ReH-0.1--Create a Session</title> </head> <body bgcolor="575757"> <center> <?php $error = "Could not connect to the database"; mysql_connect('localhost','root','') or die ($error); mysql_select_db('temp') or die ($error); //Set Variables $id = $_POST['id']; $table = $POST['table']; //Check for exsistence if (!$id or !$table) { echo "<font color='#ff0000'>You must enter a Session Name</font>"; } else { echo "Congrats!"; } ?> <h2 style="color:#fff">ReH-0.1 Password Encryption</h2><br><br> <font color="#fff">Before encrypting your password, a session must be started. We need you to enter a personal session name that you will remember so that you password is protected by this session.</font><br><br> <form action="session_start.php" method="POST"> <label for="id" style="color: #fff;">Session Name: <input type="text" maxlength="10" size="10" name="id"></label><br><br> <label for="table" style="color: #fff;">Session Name Confirmation: <input type="text" maxlength="10" size="10" name="table"></label><br><br> <input type="submit" value="Create Session"> </form> </center> </body> </html> Hi, Im pretty new to php but im have trouble understanding why my script is doing this. Forgive me for silly mistakes! Im creating a login/register website and once the person has logged in they get a message saying "Successful login, welcome username!" The php checks against a database of users in an if statement to check if the password is correct and then prints out the message. But at the end of the message the echo is printing out a 1. I get that because the echo is in an if statement its return true or 1 but I cant get it to not print out the 1. code snippet is - if ($username==$dbusername&&$password==$dbpassword) { echo "Successful login, welcome!"; } Hope that makes sense. Thanks for the help. Neil Hi im having trouble getting the below code to listen to my css margin settings. Just to clear up the server side of things, can anybody tell me wether or not im using the correct syntax in the code below? Code: [Select] else { echo("<p class=\"passed\">Thankyou for submiting your details, you will be added to our directory shortly</p>"); }} I cannot retrieve my records from my table, neither can I display them on my website. I do not even get any errors when I run the script on my site. Any help or tips would be greatly appreciated. My current php script is: // connection to database server $db_selected = mysql_select_db('database1', $dbc); if (!$db_selected) { die ('Can\'t use database1 : ' . mysql_error()); } $query = "SELECT * FROM chesstable ORDER BY chapter, lastname"; $result = mysql_query($query) or die('Could not connect' . mysql_error()); echo mysql_num_rows($result); If (!$result) { $message = 'Invalid query: ' . mysql_error(); $message = 'Whole query: ' . $query; die ($message); } while($row = mysql_fetch_assoc($result)) { echo $row['firstname'] . " " . $row['lastname'] . $row['chapter']; } mysql_free_result($result); mysql_close($dbc); ?> Hi Guys, I keep getting the following error: Parse error: syntax error, unexpected T_ECHO in /Applications/XAMPP/xamppfiles/htdocs/pet/petCatalog1.php on line 51 I have copied the code from a tutorial and cannot for the life of me work out what the problem is with line 51???? I have attached the file and pasted the code below. The real problem line is: echo "<tr><td valign='top' width='15%' style='font-weight: bold; font-size: 1.2em'\n" The full code is attached - btw, inserting the ">" does not help to fix it!! <?php /* Programme: PetCatalog.php * Desc: Lists all pet categories with radio buttons */ ?> <html> <head> <title>Select a Pet Category</title> </head> <body> <?php /* Database login info - Move to an Include */ $host="localhost"; $user="root"; $passwd=""; $dbname="information_schema"; /* Establishes a connection with the databse */ $cxn = mysqli_connect ($host, $user, $passwd, $dbname) or die ("Could not connect to the database JAMIE!"); /* SQL Query to select all categories of pet from the petType column in the pet table */ $query = "SELECT * FROM PetCatalog.petType ORDER BY petType"; $result = mysqli_query($cxn,$query) or die ("Unable to connect to the database JAMIE"); /* Echo of H1 & H2 above the pet table */ echo "<div style='margin-left: .lin'>\n <h1 style='text-align: center'>Pet Catalogue</h1>\n <h2 style='text-align: center'>The following categories of pets are now available</h2>\n"; /* Create form to diplay pet categories */ echo "<form action='ShowPets.php' method='POST'>\n"; echo "<table cellpadding='5' border='1'>"; $counter=1; while ($row = mysqli_fetch_assoc($result)) { extract ($row) echo "<tr><td valign='top' width='15%' style='font-weight: bold; font-size: 1.2em'\n" echo "<input type='radio' name='interest' value='$petType'\n"; if( $counter == 1 ) { echo "checked='checked'"; } echo ">$petType</td>"; echo "<td>$typeDescription</td></tr>"; $counter++; } echo "</table>"; echo "<p>input type='submit' value='Select Pet Type'> </form></p>\n"; ?> </body> </html> I am using the code below to attempt to show stored value only when data is present in the record set. Code: [Select] $results[] = " if ({$row['MapLocation']} != NULL ){ echo <a href=\"{$row['MapLocation']}\" target=_blank>Map</a>} "; $i++;What I see on the page is: if ( != NULL ){ echo Map} with Map being a link. I know there is a syntax error somewhere but can't find it. Open to suggestions. Thanks for your help I'm trying to call a PDO fetch from within a class I'm writing, however I have never used PDO and the documentation @ php.net is somewhat...crap. It's probably fine for people who just need a refference, but navigating it as a learning resource isn't the easiest. Anyway, I keep getting Quote Fatal error: Call to undefined method PDO::fetch() in C:\xampp\htdocs\eclipse\src\connect.php on line 85 I can post up the class if you like, but it's something of a mess to follow. This is the method that's calling the fetch : public function get($method='ASSOC'){ if($this->temp !== null){ $this->run(); //performs PDOexecute and returns resourcce to $this->resource $qry = $this->resource; if($this->rdbs == 'mysql'){ $fetch= "FETCH_".strtoupper($method); //builds the fetch type from parameter, or uses ASSOC as default. /*Ln85------------>>*/ $this->result = $this->dbo->fetch(PDO::$fetch); //performs the PDO search using the $this->dbo which is the public class PDO Object }// the stuff under here isn't used (yet) and isn't in PDO, since MS SQL Server is not supported by PDO elseif($this->rdbs == 'mssql'){ $fetch = "SQLSRV_FETCH_".strtoupper($method); $this->result = sqlsrv_fetch_array($qry, $fetch); $this->num_rows = sqlsrv_num_rows($qry); } } I built the call to mirror what I could find on the php.net site, but obviously that's not what's happening here. Can anyone point out what part of this I have screwed up? (I don't mind if the answer's all of it, so long as it comes with an explination ) I want to check to see if two variables are NOT empty and if so- assign a new variable Code: [Select] if(!empty($net_op_call) and !empty($f_name)){ $net_start = 'Yes'; } Is this syntax correct as it is not setting the variable - $net_start Ok I solved the problem, this was my initial query which didn't work: $query3 = "INSERT INTO user (avatar) VALUES ('$avatar') WHERE user_id = '$dbuser_id'"; but this one works: "UPDATE user set avatar = '$avatar' WHERE user_id = '$dbuser_id'"; My delete button will not work for some reason. I have created a loop, ordered my database entries with $i and have gotten closer, but not 100% of the way to making it work. I am trying to delete rows from my database individually. Not sure where I am going wrong with my syntax, but something is not working. The entries are not deleting nor am I receiving any errors. I am stumped. Here is the code. I shortened it for readability. Code: [Select] <?php // database connection information include('connection.php'); $query = "SELECT * FROM FORUM_MESSAGE ORDER BY MSG_DATE DESC"; $result = mysql_query($query); $num = mysql_num_rows($result); $i = 0; while ($i < $num) { $subject = mysql_result ($result, $i, "SUBJECT"); $message_text = mysql_result ($result, $i, "MSG_TEXT"); echo '<form method="POST" name="subject">'; echo '<input type="hidden" name="update" value="<?php echo $subject; ?>" />'; echo '<input type="submit" name="update" value="Update" />'; echo ' '; echo '<input type="hidden" name="delete" value="' . $subject . '" />'; echo '<input type="submit" value="Delete" />'; echo '</form>'; $i++; } if (isset($_POST['delete'])) { include ('connection.php'); mysql_query("DELETE FROM FORUM_MESSAGE WHERE SUBJECT = " . $subject); } ?> </body> </html> Thanks again! Ryan Having issues with a small piece of script. Trying to delete entries from a database. First, the essentials: the button being clicked is named 'delete' the columns in the actual table are 'INDEX' 'SUBJECT' 'MSG_TEXT' and 'MSG_DATE' Here is the code: Code: [Select] <?php if($_POST['delete']) // from button name="delete" { for($i=0;$i<$count;$i++) { $del_id = $i; $sql = "DELETE FROM FORUM_MESSAGE WHERE id='$del_id'"; $result = mysql_query($sql) or die (mysql_error()); } if($result) { header('Location: message-deleted.php'); } } ?> Thanks again! Ryan OK, have no idea what's going on... I've done this a million times... why wont this output!?? I must have a major brain meltdown and dont know it yet!!! Code: [Select] <?php // this echoes just fine: echo $_POST['testfield']; // but this wont echo: echo if (isset($_POST['testfield'])) { $_POST['testfield'] = $test; } echo $test; /// or even this DOESNT echo either!: $_POST['testfield'] = $test; echo $test; ?> the line : echo $form['catcher_id'] gives me a dropdown list when i choose another item from the dropdown i want to do a few things but my code not working: $selected_catcher = $form['catcher_id']; foreach($selected_catcher as $val) { $catcher_name = $val->getName(); echo $catcher_name." ".$val->getId(); if ($catcher_name = "zed-catcher") { echo $form['service_code']->renderLabel(); echo $form['service_code']->renderError(); echo $form['service_code']; } } please help? thanks |