PHP - What Is Correct Way Of Passing Strings To Javascript.
Hello,
I'm first time posting here, my PHP Javascript and HTML level is "trial, error, google", I've done some scripts, but now I'm facing one problem. Here's a code example: <?php $sa = array("Text without quotes.", "Text with 'quotes'.", "Text with \"Double Quotes\".", "Text With \"BOTH' kind of quotes."); echo "<A HREF='javascript:void(alert('".htmlspecialchars($sa[0], ENT_QUOTES)."'))'>Test One</A><BR/>"; echo "<A HREF='javascript:void(alert('".htmlspecialchars($sa[1], ENT_QUOTES)."'))'>Test Two</A><BR/>"; echo "<A HREF='javascript:void(alert('".htmlspecialchars($sa[2], ENT_QUOTES)."'))'>Test Three</A><BR/>"; echo "<A HREF='javascript:void(alert('".htmlspecialchars($sa[3], ENT_QUOTES)."'))'>Test Four</A><BR/>"; ?> What I'm trying to do is pass array of strings with quotes in them to my javascript, I tried using addslashes, htmlspecialchars but none of them work correctly. Whats the Right way to pass a string how do I preprocess it so javascript understands it correctly? Sorry if it's very simple or common question, I must have missed it in FAQ section. Thank you. Similar TutorialsIt's pretty simple to see what I am trying to do here. For some reason all results in the table are the same exact cityName replacing all existing records. The echoed results are correct. I've include a small dump of my table as well. $query = "SELECT cityName FROM sys_city_dev_2"; $resource = mysqli_query($cxn, $query) or die("MySQL error: " . mysqli_error($cxn) . "<hr>\nQuery: $query"); while($result = mysqli_fetch_assoc($resource)) { $nox = $result['cityName']; $toUpper = ucfirst($nox); echo "$toUpper" . "<br />"; $setString = "UPDATE sys_city_dev_2 SET cityName = '" . $toUpper ."' WHERE cityName != ''"; mysqli_query($cxn,$setString); } 100 Records of table dump (pre running my script above): -- -- Table structure for table `sys_city_dev_2_backup` -- CREATE TABLE IF NOT EXISTS `sys_city_dev_2_backup` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `Mid` int(11) NOT NULL DEFAULT '0', `cityName` varchar(30) NOT NULL DEFAULT '', `forder` int(4) NOT NULL DEFAULT '0', `disdplay` int(4) NOT NULL DEFAULT '0', `cid` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=113970 ; -- -- Dumping data for table `sys_city_dev_2_backup` -- INSERT INTO `sys_city_dev_2_backup` (`ID`, `Mid`, `cityName`, `forder`, `disdplay`, `cid`) VALUES (84010, 1, 'dothan', 0, 0, 0), (84011, 1, 'alabaster', 0, 0, 0), (84012, 1, 'birmingham', 0, 0, 0), (84013, 2, 'flagstaff', 0, 0, 0), (84014, 1, 'auburn', 0, 0, 0), (84015, 1, 'florence', 0, 0, 0), (84016, 1, 'gadsden', 0, 0, 0), (84017, 1, 'huntsville', 0, 0, 0), (84018, 1, 'mobile', 0, 0, 0), (84019, 1, 'montgomery', 0, 0, 0), (84020, 1, 'tuscaloosa', 0, 0, 0), (84021, 2, 'mohave valley', 0, 0, 0), (84022, 2, 'phoenix', 0, 0, 0), (84023, 2, 'prescott', 0, 0, 0), (84024, 2, 'sierra vista', 0, 0, 0), (84025, 2, 'tucson', 0, 0, 0), (84026, 2, 'yuma', 0, 0, 0), (84027, 3, 'bakersfield', 0, 0, 0), (84028, 3, 'chico', 0, 0, 0), (84029, 3, 'fresno / madera', 0, 0, 0), (84030, 3, 'gold country', 0, 0, 0), (84031, 3, 'humboldt county', 0, 0, 0), (84032, 3, 'imperial', 0, 0, 0), (84033, 3, 'inland empire', 0, 0, 0), (84034, 3, 'los angeles', 0, 0, 0), (84035, 3, 'alhambra', 0, 0, 0), (84036, 3, 'merced', 0, 0, 0), (84037, 49, 'fayetteville', 0, 0, 0), (84038, 49, 'fort smith', 0, 0, 0), (84039, 49, 'jonesboro', 0, 0, 0), (84040, 49, 'little rock', 0, 0, 0), (84041, 49, 'arkadelphia', 0, 0, 0), (84042, 49, 'texarkana', 0, 0, 0), (84043, 3, 'modesto', 0, 0, 0), (84044, 3, 'alta sierra', 0, 0, 0), (84045, 3, 'alpine', 0, 0, 0), (84046, 3, 'pedley', 0, 0, 0), (84047, 3, 'redding', 0, 0, 0), (84048, 3, 'alondra park', 0, 0, 0), (84049, 3, 'sacramento', 0, 0, 0), (84050, 4, 'canon city', 0, 0, 0), (84051, 3, 'san luis obispo', 0, 0, 0), (84052, 3, 'santa barbara', 0, 0, 0), (84053, 3, 'stockton', 0, 0, 0), (84054, 3, 'aliso viejo', 0, 0, 0), (84055, 3, 'visalia', 0, 0, 0), (84056, 3, 'yuba city', 0, 0, 0), (84057, 4, 'boulder', 0, 0, 0), (84058, 4, 'colorado springs', 0, 0, 0), (84059, 4, 'denver', 0, 0, 0), (84060, 4, 'applewood', 0, 0, 0), (84061, 4, 'pueblo', 0, 0, 0), (84062, 4, 'air force academy', 0, 0, 0), (84063, 5, 'avon', 0, 0, 0), (84064, 5, 'hartford', 0, 0, 0), (84065, 5, 'new haven', 0, 0, 0), (84066, 5, 'ansonia', 0, 0, 0), (84067, 5, 'fairfield', 0, 0, 0), (84068, 7, 'daytona beach', 0, 0, 0), (84069, 7, 'sebastian', 0, 0, 0), (84070, 5, 'wallingford center', 0, 0, 0), (84071, 8, 'belvedere park', 0, 0, 0), (84072, 7, 'sarasota springs', 0, 0, 0), (84073, 7, 'sandalfoot cove', 0, 0, 0), (84074, 7, 'san carlos park', 0, 0, 0), (84075, 7, 'st. augustine', 0, 0, 0), (84076, 7, 'tallahassee', 0, 0, 0), (84077, 7, 'safety harbor', 0, 0, 0), (84078, 7, 'ruskin', 0, 0, 0), (84079, 8, 'athens-clarke county', 0, 0, 0), (84080, 8, 'atlanta', 0, 0, 0), (84081, 8, 'augusta-richmond county', 0, 0, 0), (84082, 8, 'brunswick', 0, 0, 0), (84083, 8, 'columbus', 0, 0, 0), (84084, 8, 'americus', 0, 0, 0), (84085, 8, 'acworth', 0, 0, 0), (84086, 8, 'valdosta', 0, 0, 0), (84087, 10, 'boise', 0, 0, 0), (84088, 10, 'ammon', 0, 0, 0), (84089, 10, 'moscow', 0, 0, 0), (84090, 10, 'blackfoot', 0, 0, 0), (84091, 10, 'twin falls', 0, 0, 0), (84092, 10, 'meridian', 0, 0, 0), (84093, 10, 'jerome', 0, 0, 0), (84094, 10, 'idaho falls', 0, 0, 0), (84095, 11, 'addison', 0, 0, 0), (84096, 10, 'garden city', 0, 0, 0), (84097, 10, 'eagle', 0, 0, 0), (84098, 10, 'chubbuck', 0, 0, 0), (84099, 10, 'caldwell', 0, 0, 0), (84100, 12, 'bloomington', 0, 0, 0), (84101, 12, 'evansville', 0, 0, 0), (84102, 12, 'fort wayne', 0, 0, 0), (84103, 12, 'indianapolis', 0, 0, 0), (84104, 12, 'muncie / anderson', 0, 0, 0), (84105, 12, 'lafayette / west lafayette', 0, 0, 0), (84106, 12, 'south bend / michiana', 0, 0, 0), (84107, 12, 'terre haute', 0, 0, 0), (84108, 12, 'northwest indiana', 0, 0, 0), (84109, 13, 'ames', 0, 0, 0); Okay, I have been looking into this for the last 3 hours, and cant find shit. I have a page with a javascript game where the player moves around on a map. They have an X and Y coordinate, but I'm having a problem. The problem is I need to store that info in a database, and I'm having trouble learning AJAX. Heres a little list of things: Play loads the game. A php variable is taken from a database. The player goes to those X and Y coordinates. The player may move around. Once they move, the player is sent to a php page that updates the Database information. The page is refreshed to the game again, where they may then move around some more. The problem is, when the page is changed the values are lost. For some reasons cookies aren't working at all (like just not working for anything, even a completely different file.) I heard something about using $_GET or $_POST, but I dont see how... This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=355358.0 Hello Everyone! I have created a javascript array which now i want to pass to php, so php can store those values to mysql. So please anyone can suggest me how do i pass it to php? Any help will highly be appreciated! Folks, Requirement: I want to pass Javascript Output in a PHP Variable. Purpose: So that i can find a particular String from that Javascript Output and accordingly apply the control. Javascript: Quote <script type='text/javascript'> var amzn_wdgt={widget:'Search'}; amzn_wdgt.tag='powlawofatt-21'; amzn_wdgt.columns='3'; amzn_wdgt.rows='10'; amzn_wdgt.defaultSearchTerm='10 mp 5x zoom'; amzn_wdgt.searchIndex='Electronics'; amzn_wdgt.width='542'; amzn_wdgt.showImage='True'; amzn_wdgt.showPrice='True'; amzn_wdgt.showRating='True'; amzn_wdgt.design='2'; amzn_wdgt.colorTheme='Default'; amzn_wdgt.headerTextColor='#000000'; amzn_wdgt.outerBackgroundColor='#FFFFFF'; amzn_wdgt.marketPlace='GB'; </script> <script type='text/javascript' src='http://wms.assoc-amazon.co.uk/20070822/GB/js/AmazonWidgets.js'> </script> What i am doing: Quote $javaoutput = "<script type='text/javascript'> var amzn_wdgt={widget:'Search'}; amzn_wdgt.tag='powlawofatt-21'; amzn_wdgt.columns='3'; amzn_wdgt.rows='10'; amzn_wdgt.defaultSearchTerm='10 mp 5x zoom'; amzn_wdgt.searchIndex='Electronics'; amzn_wdgt.width='542'; amzn_wdgt.showImage='True'; amzn_wdgt.showPrice='True'; amzn_wdgt.showRating='True'; amzn_wdgt.design='2'; amzn_wdgt.colorTheme='Default'; amzn_wdgt.headerTextColor='#000000'; amzn_wdgt.outerBackgroundColor='#FFFFFF'; amzn_wdgt.marketPlace='GB'; </script> <script type='text/javascript' src='http://wms.assoc-amazon.co.uk/20070822/GB/js/AmazonWidgets.js'> </script>"; if (strpos($javaoutput, "No results for")) { echo "Sorry no product found"; } else echo $javaoutput; Problem: It seems its outputting the Javascript output in PHP variable $javaoutput but the strpost() does not work. What am i doing wrong? and How to correct it? Cheers Natasha Thomas Hello, I have below javascript, which I need to put in a new php page. However I need the vistiors to pass in the username to the script either by clicking the link for that user or by entering a value on the website. I am not sure how can I do this in php script and modify below java script to make it work. Any help will be greatly appreciated. <pre class="example"> $(function(){ $(".tweet").tweet({ join_text: "auto", username: "NEED_TO_BE_PARAMETER", avatar_size: 68, count: 25, auto_join_text_default: "said,", auto_join_text_ed: "I", auto_join_text_ing: "I wase", auto_join_text_reply: "I replied", auto_join_text_url: "I was checking out", loading_text: "loading..." }); }); </pre> <div class='query'></div> <script type="text/javascript"> $(function(){ $(".example").each(function(i, e){ eval($(e).text()); }); }); </script> I'm making a site where I use a javascript popup, and I want to pass in a php variable to the popup, but I'm not sure what to do. Normally, I would use $_GET but the link points to the javascript code. Basically, I want the popup to display which user was clicked, player 1 or player 2, but I don't know where to start. Sorry if this should be asked in a javascript forum, I wasn't sure who I should ask. If I've asked in the wrong place, let me know. Test.php Code: [Select] <html> <head> <script type="text/javascript" src="script/popup-window.js"></script> </head> <body> <?php $player1 = "abc"; $player2 = "def"; $javacode = "javascript:popup_show('popup', 'popup_drag', 'popup_exit', 'screen-top-left', 1200, 20)"; echo 'Player 1: <a href="'.$javacode.'">'.$player1.'</a><br />'; echo 'Player 2: <a href="'.$javacode.'">'.$player2.'</a><br />'; ?> <div class="sample_popup" id="popup" style="display: none;"> <?php echo "Player selected: "; ?> </div> </body> </html> script/popup-window.js Code: [Select] // Copyright (C) 2005-2008 Ilya S. Lyubinskiy. All rights reserved. // Technical support: http://www.php-development.ru/ // // YOU MAY NOT // (1) Remove or modify this copyright notice. // (2) Re-distribute this code or any part of it. // Instead, you may link to the homepage of this code: // http://www.php-development.ru/javascripts/popup-window.php // // YOU MAY // (1) Use this code on your website. // (2) Use this code as part of another product. // // NO WARRANTY // This code is provided "as is" without warranty of any kind. // You expressly acknowledge and agree that use of this code is at your own risk. // USAGE // // function popup_show(id, drag_id, exit_id, position, x, y, position_id) // // id - id of a popup window; // drag_id - id of an element within popup window intended for dragging it // exit_id - id of an element within popup window intended for hiding it // position - positioning type: // "element", "element-right", "element-bottom", "mouse", // "screen-top-left", "screen-center", "screen-bottom-right" // x, y - offset // position_id - id of an element relative to which popup window will be positioned // ***** Variables ************************************************************* var popup_dragging = false; var popup_target; var popup_mouseX; var popup_mouseY; var popup_mouseposX; var popup_mouseposY; var popup_oldfunction; // ***** popup_mousedown ******************************************************* function popup_mousedown(e) { var ie = navigator.appName == "Microsoft Internet Explorer"; popup_mouseposX = ie ? window.event.clientX : e.clientX; popup_mouseposY = ie ? window.event.clientY : e.clientY; } // ***** popup_mousedown_window ************************************************ function popup_mousedown_window(e) { var ie = navigator.appName == "Microsoft Internet Explorer"; if ( ie && window.event.button != 1) return; if (!ie && e.button != 0) return; popup_dragging = true; popup_target = this['target']; popup_mouseX = ie ? window.event.clientX : e.clientX; popup_mouseY = ie ? window.event.clientY : e.clientY; if (ie) popup_oldfunction = document.onselectstart; else popup_oldfunction = document.onmousedown; if (ie) document.onselectstart = new Function("return false;"); else document.onmousedown = new Function("return false;"); } // ***** popup_mousemove ******************************************************* function popup_mousemove(e) { var ie = navigator.appName == "Microsoft Internet Explorer"; var element = document.getElementById(popup_target); var mouseX = ie ? window.event.clientX : e.clientX; var mouseY = ie ? window.event.clientY : e.clientY; if (!popup_dragging) return; element.style.left = (element.offsetLeft+mouseX-popup_mouseX)+'px'; element.style.top = (element.offsetTop +mouseY-popup_mouseY)+'px'; popup_mouseX = ie ? window.event.clientX : e.clientX; popup_mouseY = ie ? window.event.clientY : e.clientY; } // ***** popup_mouseup ********************************************************* function popup_mouseup(e) { var ie = navigator.appName == "Microsoft Internet Explorer"; var element = document.getElementById(popup_target); if (!popup_dragging) return; popup_dragging = false; if (ie) document.onselectstart = popup_oldfunction; else document.onmousedown = popup_oldfunction; } // ***** popup_exit ************************************************************ function popup_exit(e) { var ie = navigator.appName == "Microsoft Internet Explorer"; var element = document.getElementById(popup_target); popup_mouseup(e); element.style.display = 'none'; } // ***** popup_show ************************************************************ function popup_show(id, drag_id, exit_id, position, x, y, position_id) { var element = document.getElementById(id); var drag_element = document.getElementById(drag_id); var exit_element = document.getElementById(exit_id); var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth; var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight; element.style.position = "absolute"; element.style.display = "block"; if (position == "element" || position == "element-right" || position == "element-bottom") { var position_element = document.getElementById(position_id); for (var p = position_element; p; p = p.offsetParent) if (p.style.position != 'absolute') { x += p.offsetLeft; y += p.offsetTop; } if (position == "element-right" ) x += position_element.clientWidth; if (position == "element-bottom") y += position_element.clientHeight; element.style.left = x+'px'; element.style.top = y+'px'; } if (position == "mouse") { element.style.left = (document.documentElement.scrollLeft+popup_mouseposX+x)+'px'; element.style.top = (document.documentElement.scrollTop +popup_mouseposY+y)+'px'; } if (position == "screen-top-left") { element.style.left = (document.documentElement.scrollLeft+x)+'px'; element.style.top = (document.documentElement.scrollTop +y)+'px'; } if (position == "screen-center") { element.style.left = (document.documentElement.scrollLeft+(width -element.clientWidth )/2+x)+'px'; element.style.top = (document.documentElement.scrollTop +(height-element.clientHeight)/2+y)+'px'; } if (position == "screen-bottom-right") { element.style.left = (document.documentElement.scrollLeft+(width -element.clientWidth ) +x)+'px'; element.style.top = (document.documentElement.scrollTop +(height-element.clientHeight) +y)+'px'; } drag_element['target'] = id; drag_element.onmousedown = popup_mousedown_window; exit_element.onclick = popup_exit; } // ***** Attach Events ********************************************************* if (navigator.appName == "Microsoft Internet Explorer") document.attachEvent ('onmousedown', popup_mousedown); else document.addEventListener('mousedown', popup_mousedown, false); if (navigator.appName == "Microsoft Internet Explorer") document.attachEvent ('onmousemove', popup_mousemove); else document.addEventListener('mousemove', popup_mousemove, false); if (navigator.appName == "Microsoft Internet Explorer") document.attachEvent ('onmouseup', popup_mouseup); else document.addEventListener('mouseup', popup_mouseup, false); This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=332103.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=348942.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=359130.0 I'm trying to send a submission to the following Craigslist form that uses javascript to trigger an auto submit. The user selects "For Sale" on my form and it will pass the data in a hidden div to the proper selection on the craigslist page. Heres the page it would be passing to. I know I will have to pass it in the URL. Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <base href="https://post.craigslist.org"> <title>houston craigslist | choose type</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <link type="text/css" rel="stylesheet" media="all" href="/styles/craigslist.css?v=9"> </head> <body id="pp"> <table width="100%" id="header" summary="header"> <tr valign="top"> <td><a href="http://houston.craigslist.org/"><b>houston craigslist</b></a> > choose type<br></td> <td width="10%" class="highlight" style="text-align: right; white-space: nowrap;"> <font size="2" face="sans-serif" color="#7a7a7a">[ logged in as <a href="https://accounts.craigslist.org/login"><b>kennymahaffey@gmail.com</b></a> ] [ <a href="https://accounts.craigslist.org/logout">logout</a> ]</font> <br></td> </tr> </table> <hr> <blockquote> <div class="highlight"> <i>Please post to a single geographic area and category only -- cross-posting to multiple cities or categories is not allowed</i> </div> <h4>What type of posting is this:</h4> <form action="https://post.craigslist.org/k/kInfxI4M4RGIA7PWTF5SWg/HjdlJ" method="POST"> <blockquote> <label> <input type="radio" name="id" value="jo" onclick="form.submit(); return false;">job offered </label> <br> <label> <input type="radio" name="id" value="jw" onclick="form.submit(); return false;">resume / job wanted </label> <br> <br> <label> <input type="radio" name="id" value="ho" onclick="form.submit(); return false;">housing offered </label> <br> <label> <input type="radio" name="id" value="hw" onclick="form.submit(); return false;">housing wanted </label> <br> <br> <label> <input type="radio" name="id" value="fs" onclick="form.submit(); return false;">for sale </label> <i>(please do not post prohibited <sup><a target="_blank" href="http://www.craigslist.org/about/prohibited.items">[?]</a></sup> or recalled <sup><a target="_blank" href="http://www.craigslist.org/about/recalled_items">[?]</a></sup> items)</i> <br> <label> <input type="radio" name="id" value="iw" onclick="form.submit(); return false;">item wanted </label> <br> <br> <label> <input type="radio" name="id" value="go" onclick="form.submit(); return false;">gig offered </label> <i>(I'm hiring for a short-term, small or odd job)</i> <br> <label> <input type="radio" name="id" value="so" onclick="form.submit(); return false;">service offered </label> <br> <br> <label> <input type="radio" name="id" value="p" onclick="form.submit(); return false;">personal / romance </label> <br> <br> <label> <input type="radio" name="id" value="c" onclick="form.submit(); return false;">community </label> <br> <label> <input type="radio" name="id" value="e" onclick="form.submit(); return false;">event </label> <br> <br> </blockquote> <input type="hidden" name="U2FsdGVkX:18yNDg2NDI0O:A8dZroeLa8K5Y677RwK4hzBe2OPdD3XxLUDb5lS9LllELhxNpMqXZIwAWDxJ.7Wo4A" value="U2FsdGVkX18yNDg2NDI0OFjS1qgWn_NKgmgnh5qCZ9aK2m7eOmS-uAAM_Pwu8VHN"> <button type="submit" name="go" value="Continue">Continue</button> </form> </blockquote> I was thinking how can I make a script that will build strings incrementing through each letter starting with "a" and ending with "zzzzzz" or what ever ending length I want such as 12. So if your were to output everything, you could find the words: "dog" "spider" "superman" "hippo" etc What would be the best way to do this, so I don't have to have a loop that is 500 blocks deep to show a word that is 500 letters example Quote a ... z aa ab ac ... az ba bb bc ... ... aaa aab aac Hi I am having troubles using a string in a cookie.. This doesnt work: setcookie("background", "$image_name", $expire, "/", ".gedoo.com"); Neither does this: setcookie("background", "" . $image_name . "", $expire, "/", ".gedoo.com"); If I write something before $image_name like: setcookie("background", "hello" . $image_name . "", $expire, "/", ".gedoo.com"); It will save "hello" in the cookie.. So in other words, $image_name doesnt look like it is defined.. But the funny thing is that this works on the same page: echo "File Uploaded Successfully!<br><img src='images/$image_name'>"; Anyone have any idea on what I am doing wrong? How can i break down strings for example i have a simple search database for products where as a user searches a term this can be one, two three words and so on. I'm using a wildcard; but i want the best way to get the possible search so i would like to break down the string into separate words and then use that to search the database using wildcards is this possible? Thanks for reading. Not sure if there is a better way to do this, but I want to check whether the value in a Sticky Field is the same as what is in the Database. If what is in the Sticky Field is *exactly* what is in the Database, then the User didn't update that field, and so I would NOT do an UPDATE. Seem reasonable? Here is where I grab the value out of the Form... Code: [Select] // **************************** // Process Each Form Field. * // **************************** foreach($_POST['answerArray'] as $questionID => $response){ // Copy trimmed Form array to PHP array. $answerArray[$questionID] = trim($response); And here is where I grab the existing value in the Database... Code: [Select] // ******************** // Check for Answer. * // ******************** // Build query. $q1 = "SELECT response FROM bio_answer WHERE member_id=? AND question_id=?"; // Prepare statement. $stmt1 = mysqli_prepare($dbc, $q1); // Bind variable to query. mysqli_stmt_bind_param($stmt1, 'ii', $memberID, $questionID); // Execute query. mysqli_stmt_execute($stmt1); // Store results. mysqli_stmt_store_result($stmt1); // Check # of Records Returned. if (mysqli_stmt_num_rows($stmt1)==1){ // Answer Found. // Bind result-set to variable. mysqli_stmt_bind_result($stmt1, $currResponse); // Fetch record. mysqli_stmt_fetch($stmt1); So I guess I want to compare $answerArray[$questionID] against $currResponse and see if there are any differences?! What is the best way to do that? Any better ideas of how to check to see if the User made any changes to a field so I only do an UPDATE if there was actually a change? Thanks, Debbie is there a way I can make something like a ticket in pdf format that can have $name or the likes echo in it? if you could help get me started, that would be great! Hey guys!! So basically what I am doing here is pulling the directory out of a url. URL ex: http://www.xxx.com/T...IS_WHAT_I_WANT/ hello, here is what i have, obviosly it doesnt work. Code: [Select] $year=$_POST['y']; $yr=substr($year,-2); $mth=$_POST['m']; $init=$_POST['initial']; $jobnumber=$yr$mth2343$init; echo "$jobnumber"; P.S. thanks to everybody for their help lately! Hello, I was wondering if someone could help me to "get" the webaddress of a current webpage and then pull off pieces of the page. All of my pages look like: http://localhost:8888/algebra_book/Chapters/Quadratic_Functions/introductory_problem.php BUT, the stuff to the left of Quadratic Functions WILL change in the future. So all will look like: *Quadratic_Functions/introductory_problem.php Then, I'd like to pull off a $chapter variable, which in this case is Quadratic_Functions and a $page_name variable which in this case will be introductory_problem. Thanks so much. |