-
Posts
1,216 -
Joined
-
Last visited
Everything posted by WebStyles
-
not quite sure what you mean but echo 'selected=\"selected\"'; is wrong. Try this echo '<select name="stand_id">'; $stand_set = getall_stands(); while ($stands = mysql_fetch_array($stand_set)){ echo '<option value="'.$stands['stand_id'].'"'; if (isset($_POST['stand_id']) == $url_show ['stand_id']) echo ' selected'; echo '>'.$stands['stand_descrip'].'</option>'; } echo '</select>';
-
man, that's quite an attitude considering I'm the only person donating my time and knowledge to try and help you so far. and yes, I did read your post: this leads me to believe that you want to present the same page again, but with the boxes that got saved in the database already ticked. So what I answered the first time will do it for you. All that is missing is grabbing the ticked values from the database and comparing with the form element values, then applying the checked="checked" to the desired ones. (this would be one line of code if you used an array) Also there's nothing messy about arrays, it would actually make your code much faster to maintain, and to implement this new feature.
-
I'll help with half: Assuming the sentences are seperated by a line break (\n) in the text file: $file = file_get_contents('filename.txt'); $sentences = explolde("\n",$file); numberofwords = 5; // pick sentences with 5 words foreach($sentences as $k=>$sentence){ $words = explode(" ",$sentence); if(sizeof($word) != $numberofwords) unset($sentences[$k]); }
-
not sure if this is what you want, <input name="category[]" value="Demons" type="checkbox" checked="checked"> will automatically check it for you. p.s. if you put all possible values in an array, you could rewrite your form in just 4 or 5 lines with a simple foreach() statement.
-
the key 'funny' exists twice, once with value 0, and once with value 1. You cannot have the same key with 2 different values. One will overwrite the other one.
-
putting code in a function gives undefined notices
WebStyles replied to senca99's topic in PHP Coding Help
variables created outside a function will not exist inside the function unless passed in to it (or referenced) variables created inside a function will not exist outside of that function unless retuned (or were referenced, or are globals like $_SESSION) you pass vars into a function like this: functionName($var1,$var2); you reference them like this: functionName(&$var1,&$var2); -
PHP Warning: Invalid argument supplied for foreach()
WebStyles replied to ebchost's topic in PHP Coding Help
you can check it with something like this: if(is_array($items)){ echo '<br>$items is an array<br>'; }else{ echo '<br>Oppss. $items is NOT an array<br>'; } -
PHP Warning: Invalid argument supplied for foreach()
WebStyles replied to ebchost's topic in PHP Coding Help
that probably means that $items is not an array. -
yep.
-
Brilliant. That code is basically what I posted for you on the first page of this topic, except you still have something wrong in it.
-
Finding the values of certain ID's on a page?
WebStyles replied to openstrife's topic in PHP Coding Help
variables names in $_POST are enclosed in quotes (double or single).. so $_POST['something']; // is valid $_POST["something"]; // is valid $_POST[something]; // NOT valid -
Finding the values of certain ID's on a page?
WebStyles replied to openstrife's topic in PHP Coding Help
just add the strings and values usinf the plus sign to concatenate: var post_form_id = document.getElementById("post_form_id").value; var fb_dtsg = document.getElementById("fb_dtsg ").value; var xhpc_composerid = document.getElementById("xhpc_composerid").value; var params = '&post_form_id=' + post_form_id + '&fb_dtsg=' + fb_dtsg + '&xhpc_composerid='+xhpc_composerid; that javascript function posts these values to your php file, so in that file you will grab these values with: $var1 = $_POST['xhpc_composerid']; -
Some php session vars not available to ajax script
WebStyles replied to braunshedd's topic in PHP Coding Help
man, that took me some time.... this is a quick fix, and not the root of the problem, but it may help you to figure out the rest. (by the way, nice code!) in control.php, where you have session_start(); $_SESSION['endFrame'] = $_POST['frameEnd']; $_SESSION['format'] = $_POST['format']; $_SESSION['currFrame'] = $_POST['frameStart']; put: session_start(); if(isset($_POST) && !empty($_POST)){ $_SESSION['endFrame'] = $_POST['frameEnd']; $_SESSION['format'] = $_POST['format']; $_SESSION['currFrame'] = $_POST['frameStart']; } now it works. I didn't go searching for the problem after this, but for some reason control.php must be loading twice and the second time $_POST is empty so the variables get reset. hope this helps -
Finding the values of certain ID's on a page?
WebStyles replied to openstrife's topic in PHP Coding Help
add something like this in your head section (it's another javascript function) Change the filename variable and the params and call it from a link in your html code just for testing purposes (like you called the previous one). and create a php file that just echo's something to test. function callPhpFile(){ var url = 'phpFileName.php'; var params = '&valid=1'; // add all variables you need to pass along here var xmlhttp = false; // check browser and create request if(window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest(); if(xmlhttp.overrideMimeType){ xmlhttp.overrideMimeType('text/xml'); } } else if(window.ActiveXObject){ try{ xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e){ try{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){ } } } if(!xmlhttp) { return false; } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState==4){ // assuming the php file echo's something, it will be returned here var result = xmlhttp.responseText; if(result != '') alert(result); } } // POST STUFF xmlhttp.open("POST", url, true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("Content-length", params.length); xmlhttp.setRequestHeader("Connection", "close"); xmlhttp.send(params); } -
Some php session vars not available to ajax script
WebStyles replied to braunshedd's topic in PHP Coding Help
that's why I thougt the problem would be in index2.php, because it actually destroys the session, but then creates a new one and sets the var file again. that would explain why you only have that variable. with he info we have seen, we're not going to reach any conclusion. wanna post the complete code? -
Displaying certain HTML elements based on conditions?
WebStyles replied to PHPBob's topic in Javascript Help
if you want to alter page options dinamically according to what the user selects, without refreshing the page, you need javascript (theres another forum that can certainly help you with that) you basically capture the users selections with onchange="" and call javascript functions that can in place add forms, images, etc to divs on your page. -
Finding the values of certain ID's on a page?
WebStyles replied to openstrife's topic in PHP Coding Help
there's a lot of info on how to update status messages, maybe start here: https://developers.facebook.com/docs/reference/rest/stream.publish/ -
Finding the values of certain ID's on a page?
WebStyles replied to openstrife's topic in PHP Coding Help
ok, cool... so now what? from what I understood, you need to perform certain actions at given intervals of time? we know we can grab the variables, now we need to know exactly when and what you would like to do with them. -
Finding the values of certain ID's on a page?
WebStyles replied to openstrife's topic in PHP Coding Help
well, I'm guessing the return from facebook is being returned in an iframe on your page (is this correct?)... you can try javascript just to test first... going back to you very first post, where you had a hidden element called 'post_form_id'... try grabbing that value with javascript (in your html's <head> section): <script> function getValue(){ var value1 = document.getElementById("post_form_id").value; alert(value1); } </script> and place a link somehwere on your page to call the javascript function after the FB login has completed... <a href="#" onclick="getValue();">clickMe</a> test this situation to see if JS can grab your variables properly (it works, I just don't know if it will work with an iFrame) and post the results so we can brainstorm a bit more. -
Some php session vars not available to ajax script
WebStyles replied to braunshedd's topic in PHP Coding Help
try this, just for my own peace of mind: remove session_unset(); and session_destroy(); from index2.php and try again. (If your variables exist at the end of control.php and not in updateAjax, they are being destroyed somewhere.) -
Finding the values of certain ID's on a page?
WebStyles replied to openstrife's topic in PHP Coding Help
since a loaded page has already executed all the php code, there are only 2 ways you can make it do something else with php: 1. jump to another page or refresh 2. use ajax (fancy way of calling other php scripts on the server without reloading the page) It's hard to give you a complete solution since you never really discussed what variables you're talking about. in your first post I got to understanding you basically had an html form with values you needed to grab when submitted, but this is not the case. my question is: what variables are we talking about exactly? things returned from the facebook login script? variables that show up in hidden forms on your page, placed there by the facebook login script? or stuff you actually had initially and you just want them to be available all other the place (in this case you need $_SESSION to store them). -
here's a nice explanation: http://www.mc2design.com/blog/php_self-safe-alternatives
-
Finding the values of certain ID's on a page?
WebStyles replied to openstrife's topic in PHP Coding Help
Ah! I think I finally understand what you need... let me say this first: PHP is a server-side scripting language, which basically means that all php code executes before your page has loaded. from what I understand, you land on a page that has those form elements and you would like to retrieve their values to send somewhere else. Since php has already executed at this point, it will be of little help. you need to use javascript to grab the values, and ajax to send them off to another php code. -
Finding the values of certain ID's on a page?
WebStyles replied to openstrife's topic in PHP Coding Help
it's one thing to post an html form (i.e. reloading the page or jumping to another page) and it's another to post variables using CURL (page does not refresh). if you're using the first option (html form posted) then your variables will be in $_POST -
Some php session vars not available to ajax script
WebStyles replied to braunshedd's topic in PHP Coding Help
In that case, I suggest you put this: echo '<pre>'; print_r($_SESSION); echo '</pre>'; at the end of each page, just to track the session variables and figure out where it's going wrong.