Jump to content

xProteuSx

Members
  • Posts

    476
  • Joined

  • Last visited

Everything posted by xProteuSx

  1. Pikachu2000 (lol, again!) You did come up with an elegant solution! I figured it out, BASED ALMOST ENTIRELY ON YOUR ELEGANT SOLUTION! Here's what I've got: <?php $arraylist = array('26|7|0|10|0|0','3|1|3|5|0|0','3|2|3|5|0|0', '3|3|3|5|0|0') ; $arrayposition = array( 0,1 ); //foreach( $arrayposition as $v ) // { // $arraylist[$v] = str_repeat( '0', strlen($arraylist[$v]) ); // } foreach ($arrayposition as $v) { $onechore = explode("|", $arraylist[$v]); $onechore[4] = 1; $chore = implode("|", $onechore); $arraylist[$v] = $chore; } $arraylist_new = implode( ', ', $arraylist ); echo $arraylist_new; ?> Output is: 26|7|0|10|1|0, 3|1|3|5|1|0, 3|2|3|5|0|0, 3|3|3|5|0|0 Magic! Thank you dear sir. Thank you, thank you, thank you. I've spent about 5 hours on this and I've come up with variations that go up to 100+ lines of code. Now I've got a beauty in about 15 lines. PS - you said you hate everything, yet you appear to like candy ...
  2. Forgot to mention (but you probably figured this out): I am breaking down the values in the array into sub-arrays, divided by the '|' character ...
  3. Pikachu2000 (lol), What would you say if I told you that, instead of 0's and 1's ... $arraylist = ( [0] => 26|7|0|10|0|0 [1] => 3|1|3|5|0|0 [2] => 3|2|3|5|0|0 [3] => 3|3|3|5|0|0 ) And that I was trying to switch the 0 to a 1 at index 4 ?? So, for example, if $arrayposition = array( 0,3 ); The I would like to update $array list from $arraylist = ( [0] => 26|7|0|10|0|0 [1] => 3|1|3|5|0|0 [2] => 3|2|3|5|0|0 [3] => 3|3|3|5|0|0 ) to $arraylist = ( [0] => 26|7|0|10|1|0 [1] => 3|1|3|5|1|0 [2] => 3|2|3|5|0|0 [3] => 3|3|3|5|0|0 ) ???? I'm sorry, but I simplified the code that I posted (insert rant about over-complication here) so yeah, values in $arraylist are not in quoted strings. Forgive me?? .... thank you by the way.
  4. I've got a data array that looks like this: $arraylist = ('00101001','10001010','00010100','01100101'); And another that looks like this: $arrayposition = (0,3); The idea is to loop through $arraylist and when the loop gets to the indexes/positions listed in the $arrayposition array, to change all of the 1's to 0's, then put the values back into a string variable. I have something like this at the moment: $chores = 1; $arraylist_new = ''; foreach ($arrayposition as $value) { if ($chores != '') { $oldvalnum = 0; foreach($arraylist as $string) { if ($value == $oldvalnum) { $string = str_replace("1", "0", $string); if ($arraylist_new == '') {$arraylist_new = $string;} else {$arraylist_new .= ', ' . $string;} } else { if ($arraylist_new == '') {$arraylist_new = $string;} else {$arraylist_new .= ', ' . $string;} } $oldvalnum++; } } } echo $arraylist_new; The idea is for the output to be: 00000000, 10001010, 00000000, 01100101. I know the code is hinda hectic, but could someone please help?? Thanks in advance!
  5. MasterACE14, You're right, in a sense. I am not cleaning, filtering, or validating (CFV) data ... YET. Right now I am working on the basic functions. The CFV of data will be worked on at a later stage. I was just hoping to be able to hide the variables that are being sent via URL; that would make it a little more difficult for malicious users to mess with the site.
  6. I do not have a form. I am passing variables using the URL.
  7. No, I'm running it on Windows 7, 64 bit. The installer says it won't work with a 64 bit OS. I downloaded the latest version from the official XAMPP website ... ???
  8. I have no idea how to set the method to POST from GET ... I think if you use this format: http://www.mysite.com?id=432 then the method is GET by default (and might always be GET). Looks like we both need a smart person to verify, because I don't qualify for this level of verification.
  9. I am building a member-based website, and I've got a bunch of buttons that lead from page to page. The links for these buttons are generated based on user ID and subsequent pages receive this variable as well. So, if you hover over the buttons, you get a link like this: http://www.mysite.com?id=423 How can I hide the last part? The '?id=423'? I must use this format of variable, and cannot resort to session variables. Is there a way to hide this portion of the links??
  10. Got it figured out: http://php.net/manual/en/function.serialize.php http://php.net/manual/en/function.unserialize.php Cheers!
  11. After some testing (keep in mind that I am pretty amateur) it seems that the word 'Array' has in itself become an array. As in: $array[0] = A $array[1] = r $array[2] = r $array[3] = a $array[4] = y Is there any way of storing an array, within an array, in a database field??
  12. I've got an array like this: $firstquarter = array('January', 'February', 'March'); Then I'm adding it to a MySQL DB as follows: $insert = "INSERT INTO sometable (months) VALUES ('$firstquarter') "; $insertresult = mysql_query($insert) or die ('Error in Insert query: ' . mysql_error()); When I use PHPMyAdmin I see a this value stored in the DB: 'Array' Can I retrieve the values, by index, from this database field??
  13. ... got it to work. It was being echo'd using PHP so I had to escape the " marks. Cheers.
  14. I thought this would work, but it didn't: <select name="category" onChange="alert("yay");" > <option></option> <option value="1">1</option> <option value="2">2</option> </select>
  15. I am trying to write a little JavaScript scriptlet, but I need to get this to work in order to figure out what's working and what's not: <select name="category" onChange.alert("yay") > <option></option> <option value="1">1</option> <option value="2">2</option> </select> Obviously I would like an alert popup that says 'yay' if the user makes a selection from the dropdown ... thanks.
  16. God, I don't even know where to look for the error log ...
  17. I've put this into a .htaccess file, but it won't work when I put this file in the local root folder of WampServer ... that's why I am looking for alternatives. HELP!!!!
  18. How / where do I edit the php.ini file to parse HTML files for PHP? I've tried about 20 different searches on Google, but I must be asking the question wrong, because I can't find how to do this. Also, I am using WampServer ... Thank you in advance.
  19. Phenomenal. Thank you very much.
  20. I am building a website that uses session variables extensively. The site is getting a little complicated, and I am starting to lose track of which session variables are assigned, and what their values are. Is there some way where I can create a piece of code that will display all of the existing session variables and their values?
  21. Very nice. In your second example, what do the two zero's mean?
  22. Right now I am using code such as this: $query = "SELECT somevalue FROM sometable WHERE id=1" $result = mysql_query($update) or die ('Error in query: ' . mysql_error()); $somevalue = ''; if (mysql_num_rows($result) == 1) { while($row = mysql_fetch_assoc($userstatsresult)) { $somevalue = $row['somevalue']; } } echo $somevalue; Is there a short-hand method to get that single value without the IF/WHILE stuff?
  23. FYI -- the .htaccess file is being read now. I figured out that you have to use: AddType application/x-httpd-php .html Instead of: AddHandler application/x-httpd-php5 .html But now, when the .html page with the PHP code loads, I get a windows popup that want's me to either "Open the File With ..." or "Save File". If I choose to open the file using my browser, the file just gets saved to my downloads directory. HELP!
  24. BTW - I did enable the Apache rewrite_module ... still no-go. PHP code is showing up as text.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.