Search Results

Search found 104 results on 5 pages for 'htmlentities'.

Page 4/5 | < Previous Page | 1 2 3 4 5  | Next Page >

  • Facebook failing on XFBML call using Yii Framework

    - by Wenzi
    I have used this same call in other IFRAME Facebook apps, but it gives me nothing at all in terms of output. I am trying it on Yii and getting nothing. <script type="text/javascript"> window.onload = function() { FB_RequireFeatures(["XFBML"], function() { FB.init('xxxxxx', 'xd_receiver.htm'); FB.XFBML.Host.get_areElementsReady().waitUnitlReady(function() { document.getElementById("container").style.visibility = "visible"; }); }); }; </script> <script type="text/javascript"> function publish() { FB_RequireFeatures(["Connect"], function() { FB.init('xxxxxx', 'xd_receiver.htm'); FB.ensureInit(function() { FB.Connect.streamPublish(); }); }); } </script> <fb:serverFbml style="width: 755px;"> <script type="text/fbml"> <fb:fbml> <fb:request-form action="http://apps.facebook.com/ixxxx" method="POST" invite="true" type="rrrrr" content="rrrrr <?php echo htmlentities("<fb:req-choice url=\"http://apps.facebook.com/XXXX\" label=\"Authorize My Application\"") ?>" > <fb:multi-friend-selector showborder="false" actiontext="Invite your friends to use SuperThief."> </fb:request-form> </fb:fbml> </script> </fb:serverFbml>

    Read the article

  • PHP - post data ends when '&' is in data.

    - by Phil Jackson
    Hi all, im posting data using jquery/ajax and PHP at the backend. Problem being, when I input something like 'Jack & Jill went up the hill' im only recieving 'Jack' when it gets to the backend. I have thrown an error at the frontend before that data is sent which alerts 'Jack & Jill went up the hill'. When I put die(print_r($_POST)); at the very top of my index page im only getting [key] => Jack how can I be loosing the data? I thought It may have been my filter; <?php function filter( $data ) { $data = trim( htmlentities( strip_tags( mb_convert_encoding( $data, 'HTML-ENTITIES', "UTF-8") ) ) ); if ( get_magic_quotes_gpc() ) { $data = stripslashes( $data ); } //$data = mysql_real_escape_string( $data ); return $data; } echo "<xmp>" . filter("you & me") . "</xmp>"; ?> but that returns fine in the test above you &amp; me which is in place after I added die(print_r($_POST));. Can anyone think of how and why this is happening? Any help much appreciated. Regards, Phil.

    Read the article

  • Merging two Regular Expressions to Truncate Words in Strings

    - by Alix Axel
    I'm trying to come up with the following function that truncates string to whole words (if possible, otherwise it should truncate to chars): function Text_Truncate($string, $limit, $more = '...') { $string = trim(html_entity_decode($string, ENT_QUOTES, 'UTF-8')); if (strlen(utf8_decode($string)) > $limit) { $string = preg_replace('~^(.{1,' . intval($limit) . '})(?:\s.*|$)~su', '$1', $string); if (strlen(utf8_decode($string)) > $limit) { $string = preg_replace('~^(.{' . intval($limit) . '}).*~su', '$1', $string); } $string .= $more; } return trim(htmlentities($string, ENT_QUOTES, 'UTF-8', true)); } Here are some tests: // Iñtërnâtiônàlizætiøn and then the quick brown fox... (49 + 3 chars) echo dyd_Text_Truncate('Iñtërnâtiônàlizætiøn and then the quick brown fox jumped overly the lazy dog and one day the lazy dog humped the poor fox down until she died.', 50, '...'); // Iñtërnâtiônàlizætiøn_and_then_the_quick_brown_fox_... (50 + 3 chars) echo dyd_Text_Truncate('Iñtërnâtiônàlizætiøn_and_then_the_quick_brown_fox_jumped_overly_the_lazy_dog and one day the lazy dog humped the poor fox down until she died.', 50, '...'); They both work as it is, however if I drop the second preg_replace() I get the following: Iñtërnâtiônàlizætiøn_and_then_the_quick_brown_fox_jumped_overly_the_lazy_dog and one day the lazy dog humped the poor fox down until she died.... I can't use substr() because it only works on byte level and I don't have access to mb_substr() ATM, I've made several attempts to join the second regex with the first one but without success. Please help S.M.S., I've been struggling with this for almost an hour. EDIT: I'm sorry, I've been awake for 40 hours and I shamelessly missed this: $string = preg_replace('~^(.{1,' . intval($limit) . '})(?:\s.*|$)?~su', '$1', $string); Still, if someone has a more optimized regex (or one that ignores the trailing space) please share: "Iñtërnâtiônàlizætiøn and then " "Iñtërnâtiônàlizætiøn_and_then_" EDIT 2: I still can't get rid of the trailing whitespace, can someone help me out?

    Read the article

  • Passing variables across a multi page form in php

    - by Chris
    Forgive me as I am a newbie. I have a multi page form in which I am using $_SESSIONS to record the variables. <?php session_start(); foreach ( $_POST as $key=>$value ) { if ( $key!="submit" ) { $value= htmlentities(stripslashes(strip_tags($value))); $_SESSION[$key] = $value; } }` I have two problems actually. When I get to a checkform.php that I made that prints out the variables, The variables from page 1 doesn't show up even though that code listed above is on each page. I am using Firefox web developers tool to disable cookies and in the php ini, I altered session.use_trans_sid to 1 to turn it on. For the final page on my checkform.php I print_r($_POST) for the final page which works fine. Why doesn't variables from page 1 not show up? What am I missing? The 2nd problem is that when I print_r($_SESSION), some fields, specifically the checkbox arrays, print as [payment] => Array [agerange] => Array [meals] => Array [mealtypes] => Array What am I missing?

    Read the article

  • RSS feed created with PHP only shows the title in the feed reader

    - by James Simpson
    I am using the following PHP code to generate the XML for an RSS feed, but it doesn't seem to be working correctly. No short description is displayed in the feed reader, all I see is the title of the article. Also, all of the articles say they were published at the same time. This is the first time I have tried to setup an RSS feed, so I'm sure I've made several stupid mistakes. $result = mysql_query("SELECT * FROM blog ORDER BY id DESC LIMIT 10"); $date = date(DATE_RFC822); header('Content-type: text/xml'); echo ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); echo ("<rss version=\"2.0\">\n"); echo ("<channel>\n"); echo ("<lastBuildDate>$date</lastBuildDate>\n"); echo ("<pubDate>$date</pubDate>\n"); echo ("<title>my website name</title>\n"); echo ("<description><![CDATA[the description]]></description>\n"); echo ("<link>http://my-domain.com</link>\n"); echo ("<language>en</language>\n"); $ch=100; while ($a = mysql_fetch_array($result)) { $headline = htmlentities(stripslashes($a['subject'])); $posturl = $a[perm_link]; $content = $a['post']; $date = date(DATE_RFC822, $a['posted']); echo ("<item>\n"); echo ("<title>$headline</title>\n"); echo ("<link>$posturl</link>\n"); echo ("<description><![CDATA[$content]]></description>\n"); echo ("<guid isPermaLink=\"true\">$posturl</guid>\n"); echo ("<pubDate>$date2</pubDate>\n"); echo ("</item>\n"); } echo ("</channel>\n"); echo ("</rss>\n");

    Read the article

  • Jquery and PHP function

    - by Sergio
    How can I this PHP function include in jquery .html? PHP function: function trim_text($string, $limit, $break="<", $pad=" ...") { $words = explode(' ', htmlentities(strip_tags($string))); $countr = count($words); if ($countr <= 8) { return $string; }else{ // return with no change if string is shorter than $limit if(strlen($string) <= $limit) return $string; $string = substr($string, 0, $limit); if(false !== ($breakpoint = strpos($string, $break, $limit))) { if($breakpoint < strlen($string) - 1) { $string = substr($string, 0, $breakpoint) . $pad; } } $last_space = strrpos(substr($string, 0, $limit), ' '); $string = substr($string, 0, $last_space); $string = strip_tags($string); return $string.$pad; } } And the Jquery part of code where I want to in ".html" part somehow call this function is: $(" .text").html('<div>'+ message +'</div>'); What I want to do is trim this "message" text using PHP function. Is it possible?

    Read the article

  • Getting XML Numbered Entities with PHP 5 DOM

    - by user343607
    Hello guys, I am new here and got a question that is tricking me all day long. I've made a PHP script, that reads a website source code through cURL, then works with DOMDocument class in order to generate a sitemap file. It is working like a charm in almost every aspect. The problem is with special characters. For compatibility reasons, sitemap files needs to have all special chars encoded as numbered entities. And I am not achieving that. For example, one of my entries - automatically read from site URLs, and wrote to sitemap file - is: http://www.somesite.com/serviços/redesign/ On the source code it should looks like: http://www.somesite.com/servi*ç*os/redesign/ Just this. But unfortunately, I am really not figuring it out how to do it. Source code file, server headers, etc... everything is encoded as UTF-8. I'm using DOMDocument and related extensions to build the XML. (Basically, DOMDocument, $obj-createElement, $obj-appendChild). htmlentities gives ç instead of ç str_replace does not work. It makes the character just vanish in the output. I was using $obj-createElement("loc", $url); on my code, and just now I read in PHP manual that I should use $document-createTextNode($page), in order to have entities encoding support. Well, it is not working either. Any idea on how to get unstuck of this? Thanks.

    Read the article

  • curl cookie not creating on success

    - by Bin
    Hi I'm using cUrl(PHP) to post a login request and store response in cookie file. In my second request I'm passing cookie in header and post data to verify it. Issue is that cookie file is not created in first succesful request results in failure for second request. Please suggest me where I'm doing wrong. $cookiefile="/var/www/html/dimdim/cook.txt"; $url_log="http://my.dimdim.com/api/auth/login"; $p_log='request={"account":"bin6k","password":"password","group":"all"}'; $url_ver="http://my.dimdim.com/api/auth/verify"; $p_ver='request={"account":"bin6k","password":"password","group":"all"}'; $ch = curl_init(); //curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile); curl_setopt($ch, CURLOPT_URL,$url_log); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $p_log); ob_start(); // prevent any output $retval=curl_exec ($ch); // execute the curl command ob_end_clean(); // stop preventing output curl_close ($ch); //print_r($retval); unset($ch); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefile); curl_setopt($ch, CURLOPT_URL,$url_ver); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $p_log); $buf2 = curl_exec ($ch); curl_close ($ch); echo "".htmlentities($buf2);

    Read the article

  • jquery draggable/droppable issue

    - by Scarface
    Hey guys I have a drag and drop function that does not fully work. What I want to do is be able to drag and drop a picture into a div and have that picture pop up in the div. I have a list of 2 pictures right now, so I have the following function echoed for each picture. Both pictures are draggable and droppable, but the first one is the only one that appears in the div, regardless of which picture gets dragged in. I am not sure what is wrong because the jquery function seems to be unique to each picture. If any one has any suggestions I would appreciate it greatly. while ($row = mysql_fetch_assoc($query)) { $image=htmlentities($row['image']); //image name $uniqid=uniqid(); //unique id for jquery functions $dirname = "usercontent/$user/images/$image"; echo "<img id=\"$uniqid\" src=\"$dirname\" width=\"75\" height=\"75\"/>"; echo "<script> $(function() { $(\"#$uniqid\").draggable({ scroll: true, scrollSensitivity: 10, scrollSpeed: 10, revert: true, helper: 'clone', cursorAt: { cursor: 'move', top: 27, left: 27 } }); $(\"#droppable2, #droppable-background , #droppable2-innerer\").droppable({ greedy: true, activeClass: 'ui-state-hover', hoverClass: 'ui-state-active', drop: function(event, ui) { $(this).addClass('ui-state-highlight').find('> p').html('Dropped!'); $('#droppable-background').css(\"background-image\",\"url($dirname)\"); } }); }); </script>"; }

    Read the article

  • How can I format Custom Data and display in autocomplete when source is an DB

    - by Andres Scarpone
    so I'm trying to get some info in the auto-complete widget like it's shown in the JQuery UI demo Demo, the only problem is they use a variable that they fill with the data they want to show, I instead want to access the data and the different description and stuff using a Data Base in MySQL, for this I have changed the source to use another php page that looks up the info. here is the code for the Auto-complete, I really don't understand the methods so I haven't changed it from the basic search. This is the JS: $(document).ready((function(){ $( "#completa" ).autocomplete({ source: "buscar.php", minLength: 1, focus: function (event, ui){ $("#completa").val(ui.item.val); return false; }; })); This is what I have in buscar.php: <?php $conec = mysql_connect(localhost, root, admin); if(!$conec) { die(mysql_error()); } else { $bd = mysql_select_db("ve_test",$conec ); if(!$bd) { die(mysql_error()); } } $termino = trim(strip_tags($_GET['term']));//Obtener el termino que envia el autocompletar $qstring = "SELECT name, descripcion FROM VE_table WHERE name LIKE '%".$termino."%'"; $result = mysql_query($qstring);//Solicitud a la Base de Datos while ($row = mysql_fetch_array($result,MYSQL_ASSOC))//Realizar un LOOP sobre los valores obtenidos { $row['value']=htmlentities(stripslashes($row['name'])); $row_set[] = $row;//build an array } echo json_encode($row_set);//Enviar los datos al autocompletar en codificacion JSON, Altamente Necesario. ?

    Read the article

  • How to take html markup from a string and escape it to work within a script?

    - by zac
    I am using wordpress as a CMS and trying to allow user fields to be input to populate the info windows in a Google Map script. I am using this to select the id and pull in the content from a custom field : $post_id = 222; $my_post = get_post($post_id); $snip = get_post_meta($post_id, 'custom-field', true); $permalink = get_permalink( $post_id ); $pass_to = '<div class="content">'.$snip.'</div><div class="moreLink"><a href="'.$permalink.'">Find out more » </a></div></div>'; var point = new GLatLng('<?php echo $lat; $lat; ?>','<?php echo $long; $long; ?>'); var marker = createMarker(point,"<?php echo $mapTitle; $mapTitle; ?>", '<?php echo $pass_to; ?>') map.addOverlay(marker); It works fine unless there is any html in the custom-field which breaks the script. I looked at htmlspcialchar and htmlentities but rather than strip everything out I would like to have it escaped so it still works and the html is intact. Any suggestions? I am pretty new to PHP and would really appreciate any pointers.

    Read the article

  • Why doesn't this PHP execute?

    - by cam
    I copied the code from this site exactly: http://davidwalsh.name/web-service-php-mysql-xml-json as follows, /* require the user as the parameter */ if(isset($_GET['user']) && intval($_GET['user'])) { /* soak in the passed variable or set our own */ $number_of_posts = isset($_GET['num']) ? intval($_GET['num']) : 10; //10 is the default $format = strtolower($_GET['format']) == 'json' ? 'json' : 'xml'; //xml is the default $user_id = intval($_GET['user']); //no default /* connect to the db */ $link = mysql_connect('localhost','username','password') or die('Cannot connect to the DB'); mysql_select_db('db_name',$link) or die('Cannot select the DB'); /* grab the posts from the db */ $query = "SELECT post_title, guid FROM wp_posts WHERE post_author = $user_id AND post_status = 'publish' ORDER BY ID DESC LIMIT $number_of_posts"; $result = mysql_query($query,$link) or die('Errant query: '.$query); /* create one master array of the records */ $posts = array(); if(mysql_num_rows($result)) { while($post = mysql_fetch_assoc($result)) { $posts[] = array('post'=>$post); } } /* output in necessary format */ if($format == 'json') { header('Content-type: application/json'); echo json_encode(array('posts'=>$posts)); } else { header('Content-type: text/xml'); echo '<posts>'; foreach($posts as $index => $post) { if(is_array($post)) { foreach($post as $key => $value) { echo '<',$key,'>'; if(is_array($value)) { foreach($value as $tag => $val) { echo '<',$tag,'>',htmlentities($val),'</',$tag,'>'; } } echo '</',$key,'>'; } } } echo '</posts>'; } /* disconnect from the db */ @mysql_close($link); } And the php doesn't execute, it just displays as plain text. What's the dealio? The host supports PHP, I use it to run a Wordpress blog and other things.

    Read the article

  • Wrong logic in If Statement?

    - by Charles
    $repeat_times = mysql_real_escape_string($repeat_times); $result = mysql_query("SELECT `code`,`datetime` FROM `fc` ORDER by datetime desc LIMIT 25") or die(mysql_error()); $output .=""; $seconds = time() - strtotime($fetch_array["datetime"]); if($seconds < 60) $interval = "$seconds seconds"; else if($seconds < 3600) $interval = floor($seconds / 60) . " minutes"; else if($seconds < 86400) $interval = floor($seconds / 3600) . " hours"; else $interval = floor($seconds / 86400) . " days"; while ($fetch_array = mysql_fetch_array($result)) { $fetch_array["code"] = htmlentities($fetch_array["code"]); $output .= "<li><a href=\"http://www.***.com/code=" . htmlspecialchars(urlencode($fetch_array["code"])) . "\" target=\"_blank\">" . htmlspecialchars($fetch_array["code"]) . "</a> (" . $interval . ") ago.</li>"; } $output .=""; return $output; Why is this returning janice (14461 days) instead of janice (15 minutes ago) The datetime function table has the DATETIME type in my table so it's returning a full string for the date.

    Read the article

  • How to validate an array in a PHP form?

    - by SlAcKeR
    I'm fairly new to php and was wondering how do I validate the array for the states and where do I place the php code at? I already did the address part but I'm stuck at the states part. Here is the validation code. if (isset($_POST['contact_info_submitted'])) { // Handle the form. $address = mysqli_real_escape_string(htmlentities($_POST['address'])); } Here is the form code. <li><label for="address-1">Address 1: </label><input type="text" name="address-1" id="address-1" size="25" class="input-size" value="<?php if (isset($_POST['address'])) echo $_POST['address']; ?>" /></li> <li><label for="state-province">State/Province: </label> <?php echo '<select name="state-province" id="state-province">' . "\n"; foreach($state_options as $option) { if ($option == $state) { echo '<option value="' . $option . '" selected="selected">' . $option . '</option>' . "\n"; } else { echo '<option value="'. $option . '">' . $option . '</option>'."\n"; } } echo '</select>'; ?> </li>

    Read the article

  • how to disable an onclick event?

    - by user1819709
    <form id="QandA" action="<?php echo htmlentities($action); ?>" method="post"> <table id="question"> <tr> <td colspan="2"> <a onclick="return plusbutton();"> <img src="Images/plussign.jpg" width="30" height="30" alt="Look Up Previous Question" class="plusimage" id="mainPlusbutton" name="plusbuttonrow"/> </a> <span id="plussignmsg">(Click Plus Sign to look up Previous Questions)</span> </td> </tr> </table> </form> In the code above I am able to replace an image with another image when the if statement is met. But my problem is that when the image is replaced, it does not disable the on click event. My question is that when the image is replaced, how do I disable the onclick event onclick="return plusbutton();?

    Read the article

  • A problem of a repeated parameter in the pagination links?

    - by myaccount
    The problem is that when I load page 2 for example the URL becomes: http://domain.com/index.php?restaurant-id=45&currentpage=2 And that's fine but when I get to page 3 it becomes: http://domain.com/index.php?restaurant-id=45&currentpage=2&currentpage=3 And so on, it adds one more currentpage parameter everytime a new page is loaded from the pagination links! I wonder how this problem can be fixed? Here's some of the pagination function's code /****** build the pagination links ******/ // Getting current page URL with its parameters $current_page_url = ($_SERVER["PHP_SELF"].(isset($_SERVER["QUERY_STRING"])?"?".htmlentities($_SERVER["QUERY_STRING"]):"")); // Determine which sign to use (? or &) before the (currentpage=xx) parameter $sign = preg_match('/\?/', $current_page_url) ? '&' : '?'; $pagination_links = ''; // if not on page 1, don't show back links if ($currentpage > 1) { // show << link to go back to page 1 $pagination_links .= " <a href='{$current_page_url}{$sign}currentpage=1'>First page</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back 1 page $pagination_links .= " <a href='{$current_page_url}{$sign}currentpage=$prevpage'>previous</a> "; } else { $pagination_links .= "? ?"; }// end if

    Read the article

  • PHP & MySQL - Undefined variable problem?

    - by TaG
    I keep getting the following error Undefined variable: password on line 33 how do I correct this problem? So this error will stop showing. Here is the php code. $first_name = mysqli_real_escape_string($mysqli, $purifier->purify(htmlentities(strip_tags($_POST['first_name'])))); $password1 = mysqli_real_escape_string($mysqli, $purifier->purify(strip_tags($_POST['password1']))); $password2 = mysqli_real_escape_string($mysqli, $purifier->purify(strip_tags($_POST['password2']))); // Check for a password and match against the confirmed password: if ($password1 == $password2) { $sha512 = hash('sha512', $password1); $password = mysqli_real_escape_string($mysqli, $sha512); } else { echo '<p class="error">Your password did not match the confirmed password!</p>'; } //If the table is not found add it to the database if (mysqli_num_rows($dbc) == 0) { $mysqli = mysqli_connect("localhost", "root", "", "sitename"); $dbc = mysqli_query($mysqli,"INSERT INTO users (user_id, first_name, password) VALUES ('$user_id', '$first_name', '$password')"); } //If the table is in the database update each field when needed if ($dbc == TRUE) { $dbc = mysqli_query($mysqli,"UPDATE users SET first_name = '$first_name', password = '$password' WHERE user_id = '$user_id'"); echo '<p class="changes-saved">Your changes have been saved!</p>'; }

    Read the article

  • Can I retain a Google apps session token permanently for a specific user who logs into my google app

    - by Ali
    Hi guys, is it possible to retain upon authorization a single session token for a user who signs into my gogle application. CUrrently my application seems to every now and then require the user to authenticate into google apps. I think it has to do with session dying out or so. I have the following code: function getCurrentUrl() { global $_SERVER; $php_request_uri = htmlentities(substr($_SERVER['REQUEST_URI'], 0, strcspn($_SERVER['REQUEST_URI'], "\n\r")), ENT_QUOTES); if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') { $protocol = 'https://'; } else { $protocol = 'http://'; } $host = $_SERVER['HTTP_HOST']; if ($_SERVER['SERVER_PORT'] != '' && (($protocol == 'http://' && $_SERVER['SERVER_PORT'] != '80') || ($protocol == 'https://' && $_SERVER['SERVER_PORT'] != '443'))) { $port = ':' . $_SERVER['SERVER_PORT']; } else { $port = ''; } return $protocol . $host . $port . $php_request_uri; } function getAuthSubUrl($n=false) { $next = $n?$n:getCurrentUrl(); $scope = 'http://docs.google.com/feeds/documents https://www.google.com/calendar/feeds/ https://spreadsheets.google.com/feeds/ https://www.google.com/m8/feeds/ https://mail.google.com/mail/feed/atom/'; $secure = false; $session = true; //echo Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session);; return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session).(isset($_SESSION['domain'])?'&hd='.$_SESSION['domain']:''); } function _regenerate_token() { global $BASE_URL; if(!$_SESSION['token']) { if(isset($_GET['token'])): $_SESSION['token'] = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']); return; else: _regenerate_sessions(); _redirect(getAuthSubUrl($BASE_URL . '/index.php?'.$_SERVER['QUERY_STRING'])); endif; } } _regenerate_token(); I know I'm doing it all wrong here and I don't know why :( I have a CONSUMER SECRET code but only use it whereever I need to access a google service. However something is wrong with my authentication as the user has to periodically 'grant access to my application' and reauthorise himself... help please

    Read the article

  • Error while sending email to Multiple Addresses From MYSQL Database using PHP

    - by user1751581
    I am trying to send an email to multiple email addresses which are contained in a database and sorted into a recordset... The recordset has multiple columns, but I only need one: "Email". I know that if I have them in an array I can implode them and separate them by commas, but I'm not sure how I could do that with a recordset column. Anyone know how? BTW I know I have the mail function commented out... The echo is returning null... Heres the code that I tried: $colname_rsAllLeads = "-1"; if (isset($_SESSION['MM_Username'])) { $colname_rsAllLeads = $_SESSION['MM_Username']; } mysql_select_db($database_myBackOfficeConn, $myBackOfficeConn); $query_rsAllLeads = sprintf("SELECT Email FROM Leads WHERE `User` = %s ORDER BY FullName ASC", GetSQLValueString($colname_rsAllLeads, "text")); $rsAllLeads = mysql_query($query_rsAllLeads, $myBackOfficeConn) or die(mysql_error()); $row_rsAllLeads = mysql_fetch_assoc($rsAllLeads); $totalRows_rsAllLeads = mysql_num_rows($rsAllLeads); $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form")) { $startcode = $_POST['messagefield']; $replaced = preg_replace( '/\\\\(?="|\')/', '', $startcode ); echo $replaced; $collectedleads = implode(',', $row_rsAllLeads['Email']); echo $collectedleads; /* $to = $collectedleads; $subject = $_POST['subjectfield']; $body = $replaced; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: " . $row_rs_CurrentUser['FirstName'] . " " . $row_rs_CurrentUser['LastName'] . " <" . $row_rs_CurrentUser['Email'] . ">"; if (mail($to, $subject, $body, $headers)) { } else { echo("<p>Message delivery failed...</p>"); } */ $insertSQL = sprintf("INSERT INTO PendingEmails (`to`, subject, message) VALUES (%s, %s, %s)", GetSQLValueString($row_rsAllLeads['Email'], "text"), GetSQLValueString($_POST['subjectfield'], "text"), GetSQLValueString($_POST['messagefield'], "text")); mysql_select_db($database_myBackOfficeConn, $myBackOfficeConn); $Result1 = mysql_query($insertSQL, $myBackOfficeConn) or die(mysql_error()); $insertGoTo = "Email Sent.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } When I use var_dump($row_rsAllLeads['Email']) it outputs string(16) "[email protected]" but I know that there is no error in my SQL query because when I put them in a select box, they all show up...

    Read the article

  • for loop with count from array, limit output? PHP

    - by Philip
    print '<div id="wrap">'; print "<table width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"3\" cellspacing=\"3\">"; for($i=0; $i<count($news_comments); $i++) { print ' <tr> <td width="30%"><strong>'.$news_comments[$i]['comment_by'].'</strong></td> <td width="70%">'.$news_comments[$i]['comment_date'].'</td> </tr> <tr> <td></td> <td>'.$news_comments[$i]['comment'].'</td> </tr> '; } print '</table></div>'; $news_comments is a 3 diemensional array from mysqli_fetch_assoc returned from a function elsewhere, for some reason my for loop returns the total of the array sets such as [0][2] etc until it reaches the max amount from the counted $news_comments var which is a return function of LIMIT 10. my problem is if I add any text/html/icons inside the for loop it prints it in this case 11 times even though only array sets 1 and 2 have data inside them. How do I get around this? My function query is as follows: function news_comments() { require_once '../data/queries.php'; // get newsID from the url $urlID = $_GET['news_id']; // run our query for newsID information $news_comments = selectQuery('*', 'news_comments', 'WHERE news_id='.$urlID.'', 'ORDER BY comment_date', 'DESC', '10'); // requires 6 params // check query for results if(!$news_comments) { // loop error session and initiate var foreach($_SESSION['errors'] as $error=>$err) { print htmlentities($err) . 'for News Comments, be the first to leave a comment!'; } } else { print '<div id="wrap">'; print "<table width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"3\" cellspacing=\"3\">"; for($i=0; $i<count($news_comments); $i++) { print ' <tr> <td width="30%"><strong>'.$news_comments[$i]['comment_by'].'</strong></td> <td width="70%">'.$news_comments[$i]['comment_date'].'</td> </tr> <tr> <td></td> <td>'.$news_comments[$i]['comment'].'</td> </tr> '; } print '</table></div>'; } }// End function Any help is greatly appreciated.

    Read the article

  • login not working when changing from mysql to mysqli

    - by user1438647
    I have a code below where it logs a teacher in by matching it's username and password in the database, if correct, then log in, if incorrect, then display a message. <?php session_start(); $username="xxx"; $password="xxx"; $database="mobile_app"; $link = mysqli_connect('localhost',$username,$password); mysqli_select_db($link, $database) or die( "Unable to select database"); foreach (array('teacherusername','teacherpassword') as $varname) { $$varname = (isset($_POST[$varname])) ? $_POST[$varname] : ''; } ?> <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post" id="teachLoginForm"> <p>Username</p><p><input type="text" name="teacherusername" /></p> <!-- Enter Teacher Username--> <p>Password</p><p><input type="password" name="teacherpassword" /></p> <!-- Enter Teacher Password--> <p><input id="loginSubmit" type="submit" value="Login" name="submit" /></p> </form> <?php if (isset($_POST['submit'])) { $query = " SELECT * FROM Teacher t WHERE (t.TeacherUsername = '".mysqli_real_escape_string($teacherusername)."') AND (t.TeacherPassword = '".mysqli_real_escape_string($teacherpassword)."') "; $result = mysqli_query($link, $query); $num = mysqli_num_rows($result); $loged = false; while($row = mysqli_fetch_array($result)) { if ($_POST['teacherusername'] == ($row['TeacherUsername']) && $_POST['teacherpassword'] == ($row['TeacherPassword'])) { $loged = true; } $_SESSION['teacherforename'] = $row['TeacherForename']; $_SESSION['teachersurname'] = $row['TeacherSurname']; $_SESSION['teacherusername'] = $row['TeacherUsername']; } if ($loged == true){ header( 'Location: menu.php' ) ; }else{ echo "The Username or Password that you Entered is not Valid. Try Entering it Again."; } mysqli_close($link); } ?> Now the problem is that even if the teacher has entered in the correct username and password, it still doesn't let the teacher log in. When the code above was the old mysql() code, it worked fine as teacher was able to login when username and password match, but when trying to change the code into mysqli then it causes login to not work even though username and password match. What am I doing wrong?

    Read the article

  • how to disable on click event

    - by user1819709
    function insertQuestion(form) { var x = "<img src='Images/plussigndisabled.jpg' width='30' height='30' alt='Look Up Previous Question' class='plusimage' name='plusbuttonrow'/><span id='plussignmsg'>(Click Plus Sign to look <br/> up Previous Questions)</span>" ; if (qnum == <?php echo (int)$_SESSION['textQuestion']; ?>) { $('#mainPlusbutton').replaceWith(x); } //append rows into a table code, not needed for this question } .... $('.plusimage').live('click', function() { plusbutton($(this)); }); function plusbutton(plus_id) { // Set global info plusbutton_clicked = plus_id; // Display an external page using an iframe var src = "previousquestions.php"; $.modal('<iframe src="' + src + '" style="border:0;width:100%;height:100%;">'); return false; } <form id="QandA" action="<?php echo htmlentities($action); ?>" method="post"> <table id="question"> <tr> <td colspan="2"> <a onclick="return plusbutton();"> <img src="Images/plussign.jpg" width="30" height="30" alt="Look Up Previous Question" class="plusimage" id="mainPlusbutton" name="plusbuttonrow"/> </a> <span id="plussignmsg">(Click Plus Sign to look up Previous Questions)</span> </td> </tr> </table> <table id="questionBtn" align="center"> <tr> <th> <input id="addQuestionBtn" name="addQuestion" type="button" value="Add Question" onClick="insertQuestion(this.form)" /> </th> </tr> </table> </form> In the code above I am able to replace an image with another image when the if statement is met. But my problem is that when the image is replaced, it does not disable the on click event. My question is that when the image is replaced, how do I disable the onclick event onclick="return plusbutton();? Could unbind click work in this situation. I don't want to use href=# because I don't want to include # at the end of the url

    Read the article

  • Facebook invites partialy working..

    - by dugi007
    Hello! im new to facebook api and i have a litle problem.. i created iframe app and im using the folowing code to invite my friends. invitation screen renders and im able to send invitation. when someone accepts invitation it redirects them to the following link: http://www.facebook.com/reqs.php#!//apps.facebook.com/erste_app/ and nothing happens (only the facebook header apears and thats all)...when they manualy repost that link they are redirected to app and everything works... <?php include 'facebook.php'; define( 'FB_API_KEY', 'e23463********9c7ebfd6d34' ); define( 'FB_SECRET', '5f6************7efff5c8cb8' ); define( 'FB_APPID', '312*********23' ); define( 'FB_CANVAS_URL', 'http://apps.facebook.com/erste_app/' ); define( 'FB_APP_HOME_URL', 'http://www.bijelarukavica.com/test/' ); define( 'FB_APP_NAME', 'Zaigraj s Rokom' ); $bOK=SendStandardInvitation("", false); function SendStandardInvitation($to, $bNewStyle = true) { $typeword = FB_APP_NAME; // Warning: double quotes in the content string will screw up the invite signature process $content = '<fb:req-choice url=\' ' . FB_CANVAS_URL . '\' label=\'Check out ' . FB_APP_NAME . ' />'; // if your have post add routines take them to that add app URL instead. $actionText = 'Probaj jesi bolji od mene uz "' . FB_APP_NAME . '".'; $bOK = SendNewRequest($to, $typeword, $content, $actionText); return $bOK; } function SendNewRequest($to, $typeword, $content, $actionText, $bInvitation = true) { $facebook = new Facebook(FB_API_KEY,FB_SECRET); $to = implode(",", $facebook->api_client->friends_get('','')); $bInviteAll = (!$to || $to == "" ? true : false); $excludeFriends = null; if (!$bInviteAll) $excludeFriends = $facebook->api_client->friends_get(); else // Get all friends with the app $excludeFriends = $facebook->api_client->friends_getAppUsers(); $excludeFriendsStr = null; foreach ($excludeFriends as $userid) { $pos = strpos($to, (string)$userid); if ($pos !== false) continue; if ($excludeFriendsStr) $excludeFriendsStr .= ','; $excludeFriendsStr .= $userid; } $params = array(); $params['api_key'] = FB_API_KEY; $params['content'] = $content; // Don't use htmlentities() or urlencode() here $params['type'] = $typeword; $params['action'] = FB_CANVAS_URL ; $params['actiontext'] = $actionText; $params['invite'] = ($bInvitation ? 'true' : 'false'); $params['rows'] = '5'; $params['max'] = '20'; $params['exclude_ids'] = $excludeFriendsStr; $params['sig'] = $facebook->generate_sig($params, FB_SECRET); $qstring = null; foreach ($params as $key => $value) { if ($qstring) $qstring .= '&'; $qstring .= "$key=".urlencode($value); } $inviteUrl = 'http://www.facebook.com/multi_friend_selector.php?'; $facebook->redirect($inviteUrl . $qstring); return true; } $facebook->api_client->notifications_sendRequest function SendRequest($to, $typeword, $content, $bInvitation = true) { $facebook = new Facebook(FB_API_KEY,FB_SECRET); $image = FB_APP_HOME_URL . 'logo.gif'; $result = $facebook->api_client->notifications_sendRequest($to, $typeword, $content, $image, $bInvitation); $url = $result; if (isset($url) && $url) { $facebook->redirect($url . '&canvas=1&next=index.php'); return true; } $bOK = ($result && $result != ""); return $bOK; } SendStandardInvitation($to, $bNewStyle = false) ?>

    Read the article

  • PHP - DOM class - numbered entities and encodings problem

    - by user343607
    Hi guys, I'm having some difficult with PHP DOM class. I am making a sitemap script, and I need the output of $doc-saveXML() to be like <?xml version="1.0" encoding="UTF-8"?> <root> <url> <loc>http://www.somesite.com/servi&#xE7;os/redesign</loc> </url> </root> or <?xml version="1.0" encoding="UTF-8"?> <root> <url> <loc>http://www.somesite.com/servi&#231;os/redesign</loc> </url> </root> but I am getting: <?xml version="1.0" encoding="UTF-8"?> <root> <url> <loc>http://www.somesite.com/servi&amp;#xE7;os/redesign</loc> </url> </root> This is the closet I could get, using a replace named to numbered entities function. I was also able to reproduce <?xml version="1.0" ?> <root> <url> <loc>http://www.somesite.com/servi&amp;#xE7;os/redesign</loc> </url> </root> But without the encoding specified. The best solution (the way I think the code should be written) would be: <?php $myArray = array(); // do some stuff to populate the with URL strings $doc = new DOMDocument('1.0', 'UTF-8'); // here we modify some property. Maybe is the answer I am looking for... $urlset = doc->createElement("urlset"); $urlset = $doc->appendChild($urlset); foreach($myArray as $address) { $url = $doc->createElement("url"); $url = $urlset->appendChild($url); $loc = $doc->createElement("loc"); $loc = $url->appendChild($loc); $valueContent = $doc->createTextNode($value); $valueContent = $loc->appendChild($address); } echo $doc->saveXML(); ?> Notes: Server response header contains charset as UTF-8; PHP script is saved in UTF-8; URLs read are UTF-8 strings; Above script contains encoding declaration on DOMDocument constructor, and does not use any convert functions, like htmlentities, urlencode, utf8_encode... I've tried changing the DOMDocument properties DOMDocument::$resolveExternals and DOMDocument::$substituteEntities values. None combinations worked. And yes, I know I can made all process without specifying the character set on DOMDocument constructor, dump string content into a variable and make a very simple string substitution with string replace functions. This works. But I would like to know where I am slipping, how can this be made using native API's and settings, or even if this is possible. Thanks in advance.

    Read the article

  • Retreiving multiple rows from a loop-created form... Stuck.

    - by hangston
    Hi All, Let me start by saying that I'm new to PHP, but I'm here to learn and would really appreciate your help. I use the following code to pull in data and create a form. This creates up to 40 lines for a user to fill out. Each line consists of the same information: Description, Amount, and Frequency. The remainder of the information needed is generated by the database. (See hidden fields) <?php $row = 0; do { $optid = $row_options['option_id']; echo "<tr>\n\t<td>" . htmlentities($row_options['option']) . "</td>\n"; echo "\t<td>" . "<input name='description' type='text' size='40' maxlength='120'/>" . "</td>\n"; echo "\t<td>" . "<input name='option_id' type='hidden' value='$optid' />$<input name='amount' type='text' size='10' maxlength='7'/>" . "</td>\n"; echo "\t<td>" . "<select name='assisted_frequency'> <option value='Monthly'>Monthly</option> <option value='Weekly'>Weekly</option> <option value='Daily'>Daily</option> <option value='Hourly'>Hourly</option> <option value='One-Time'>One-Time</option> </select>" . "</td>\n</tr>\n"; $array[$row] = array( $arraydesc[$row] = $_POST['description'], $arrayamto[$row] = $_POST['amount'], $arrayoptid[$row] = $optid, $arrayfreq[$row] = $_POST['frequency'], ); $row ++; } while ($row_options = mysql_fetch_assoc($options)); $counter = $row - 1; ?> I'm having troubles retrieving the information that the user inputs. My intent is to loop through each row after the user has input their information, then upload the mix of my database information and the user's information into another database. For example, the user would see, albeit prettier: form1 Option 1: description [input box] amount [input box] frequency [option box] Option 2: description [input box] amount [input box] frequency [option box] Option 3: description [input box] amount [input box] frequency [option box] Option 4: description [input box] amount [input box] frequency [option box] submit Upon submitting the form above, I'm using a query similar to the following to input the data into the database: for($row=0; $row<=$counter; $row++){ $insertSQL2 = sprintf("INSERT INTO table (option_id, amount, description, frequency) VALUES (%s, %s, %s, %s)", GetSQLValueString($arrayoptid[$row], "int"), GetSQLValueString($arrayamto[$row], "int"), GetSQLValueString($arraydesc[$row], "text"), GetSQLValueString($arrayfreq[$row], "text")); // code to submit query } I've tried for, foreach, arrays (what feels like the everything I know) to post each row (row by row) into the database. I either get just the last row of data, or no data at all. I also worry that the [$row] technique is adding characters to my data. What is the best way to retrieve each row of the user's inputs, then upload this data (row by row) into the database? Also, I would really appreciate your suggestions for improving my coding technique and the approach I'm taking. Thank you, Hangston

    Read the article

< Previous Page | 1 2 3 4 5  | Next Page >