Jump to content

Search the Community

Showing results for tags 'php array'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 8 results

  1. Hi All, I am using the below with great success. It finds for me the MIn and max values allong with the company names. The problem that has just presented itself is some of the data returned in the SLevel is text. I need to ignore text and only include numeric values. Is this possible. I have tried to work this out but have hit a brick wall. Many thanks Jon $SLevels = array(); foreach ($xml->Type->Company as $item) { $companyName = (string) $item->Name; // get the company name $tmp = (array) $item->$Level; if($tmp[0] != '-') $SLevels[] = array($tmp[0], $companyName); // add SLevel and company name to array } $minSLevel = min($SLevels); // get minimum value $minSLevel[0] = str_replace(',', '', $minSLevel[0]); $premium = $minSLevel[0]; $company = $minSLevel[1]; $maxSLevel = max($SLevels); // get minimum value $maxSLevel[0] = str_replace(',', '', $maxSLevel[0]); $maxpremium = $maxSLevel[0]; $maxcompany = $maxSLevel[1];
  2. hi mate, i have this json output and i need this to be in php array how can i do this, events : [ {'id':1, 'start': new Date(year, month, day, 12), 'end': new Date(year, month, day, 13, 00), 'title': 'Lunch with Sarah', userId: [1, 2]}, {'id':2, 'start': new Date(year, month, day, 14), 'end': new Date(year, month, day, 14, 40), 'title': 'Team Meeting', userId: 0}, ], free: [ {'start': new Date(year, month, day-1, , 'end': new Date(year, month, day-1, 18), 'free': true, userId: [0,1,2,3]}, {'start': new Date(year, month, day, , 'end': new Date(year, month, day+0, 18), 'free': true, userId: [0,1,2,3]}, ] Thanks in advance
  3. So I am an intern doing PHP development, the issue is I am having a hard time understanding what a colleague of mine wrote: $x=(array) $child->tid; $tagname = (string) $child->name[0]; Just in a broad sense why does he initialize $x = (array)? etc.. I never seen this syntax, my OOP isnt as well as it should be, but any help is appreciated. I cant post the code because my boss is wary of people stealing code.
  4. OK i am very new to PHP so please be gentle LOL. I am posting a form to Liveaddress API and then i get the response back in an array it looks like this Array ( [0] => Array ( [input_index] => 0 [candidate_index] => 0 [delivery_line_1] => 13700 Oakland St [last_line] => Highland Park MI 48203-3173 [delivery_point_barcode] => 482033173009 [components] => Array ( [primary_number] => 13700 [street_name] => Oakland [street_suffix] => St [city_name] => Highland Park [state_abbreviation] => MI [zipcode] => 48203 [plus4_code] => 3173 [delivery_point] => 00 [delivery_point_check_digit] => 9 ) [metadata] => Array ( [record_type] => S [zip_type] => Standard [county_fips] => 26163 [county_name] => Wayne [carrier_route] => C021 [congressional_district] => 14 [rdi] => Commercial [elot_sequence] => 0024 [elot_sort] => A [latitude] => 42.40858 [longitude] => -83.08783 [precision] => Zip9 ) [analysis] => Array ( [dpv_match_code] => Y [dpv_footnotes] => AABB [dpv_cmra] => N [dpv_vacant] => N [active] => Y [footnotes] => L# ) ) ) How would i take primary_number and turn that into a variable to then insert into a database? Thanks, T
  5. Hello, I cannot figure this out... I will leave out most of the code to not confuse you, but I have it almost working so I am just missing something. I have two arrays, one that contains the IDS that I want correctly. Here is the first array when I print it out: Array ( [0] => 3 [1] => 9 [2] => 11 ) Perfect, it displays the IDS 3, 9, and 11 like it should. Now here is my second array when printed out: Array ( [0] => name value [1] => maker value [2] => year value ) That works too. name value, maker value, and year value are the results. I tried using an array_merge on those two arrays hoping that it will turn it into 3 => 'name value', 9 => 'maker value', 11 => 'year value' For some reason the result I get when I merge these two arrays is: Array ( [0] => 3 [1] => 9 [2] => 11 [3] => name value [4] => maker value [5] => year value ) It does merge them, but as separate array values. So when I use my foreach() to insert the values into a DB, I get this as a result: INSERT INTO fields_table (field_id, field_value) VALUES ('0', '3') INSERT INTO fields_table (field_id, field_value) VALUES ('1', '9') INSERT INTO fields_table (field_id, field_value) VALUES ('2', '11') INSERT INTO fields_table (field_id, field_value) VALUES ('3', 'name value') INSERT INTO fields_table (field_id, field_value) VALUES ('4', 'maker value') INSERT INTO fields_table (field_id, field_value) VALUES ('5', 'year value') What do I do to make the first values equal the second values please? Thanks. EDIT HAHA I finally figured this out when creating this topic! I have to use array_combine() instead of array_merge it works perfect now Nevermind I solved it!
  6. I'm trying to build a form for a TCG i run where it allow people to vote for decks they want to see released. It would show in the database by adding 1 for yes and nothing for no. I have it coded but I can't get it to update the database does anyone see where I went wrong? <?php session_start(); if (isset($_SESSION['USR_LOGIN'])=="") { header("Location:http://leisure.day-is-gone.net/login.php"); } include("mytcg/settings.php"); include("$header"); if(!$_SERVER['QUERY_STRING']) { $select = mysql_query("SELECT * FROM `$table_members` WHERE name='$_SESSION[USR_LOGIN]'"); while($row=mysql_fetch_assoc($select)) { ?> <h1>Release Me Form</h1> Chose an option for all.<Br> <?php $select2 = mysql_query("SELECT * FROM `$table_cards` WHERE released='N' AND `voted` NOT LIKE '$_SESSION[USR_LOGIN]' ORDER BY set2, category, deckname"); $count = mysql_num_rows($select2); if($count==0) { echo "There are currently no requested decks.\n"; echo "<br /><br />\n\n"; } else { echo "<table width=\"100%\">\n"; echo "<form method=\"post\" action=\"forms_reme2.php?thanks\"> <input type=\"hidden\" name=\"name\" value=\"$row[name]\" /> <input type=\"hidden\" name=\"email\" value=\"$row[email]\" />"; echo "<tr><td width=\"50%\"><b>Deckname</b></td><td width=\"25%\"><b>Category</b></td><td width=\"10%\"><b>Yes</b></td><td width=\"10%\"><b>No</b></td></tr>\n"; while($row2=mysql_fetch_assoc($select2)) { $cat=$row2[category]; if ($row2[groupmember]=="No") { echo " <input type=\"hidden\" name=\"id\" value=\"$row2[id]\" /><tr><td>$row2[deckname]</td><td>$category[$cat]</td><td><input name=\"reme[$row2[id]]\" value=\"1\" type=\"radio\">Yes</td><td><input name=\"reme[$row2[id]]\" value=\"0\" type=\"radio\">No</td></tr>\n"; } else { echo "<input type=\"hidden\" name=\"id\" value=\"$row2[id]\" /><tr><td>$row2[set2]: $row2[deckname]</td><td>$category[$cat]</td><td><input name=\"reme[$row2[id]]\" value=\"1\" type=\"radio\">Yes</td><td><input name=\"reme[$row2[id]]\" value=\"0\" type=\"radio\">No</td></tr>"; }} echo "</table>\n"; echo "<br /><br />\n"; } ?> <tr><td> </td><td><input type="submit" name="submit" value="Release It! " /></td></tr> </table> </form> <?php } } elseif($_SERVER['QUERY_STRING']=="thanks") { if (!isset($_POST['submit']) || $_SERVER['REQUEST_METHOD'] != "POST") { exit("<p>You did not press the submit button; this page should not be accessed directly.</p>"); } else { $exploits = "/(content-type|bcc:|cc:|document.cookie|onclick|onload|javascript|alert)/i"; $profanity = "/(beastial|bestial|blowjob|clit|cum|cunilingus|cunillingus|cunnilingus|cunt|ejaculate|fag|felatio|fellatio|fuck|fuk|fuks|gangbang|gangbanged|gangbangs|hotsex|jism|jiz|kock|kondum|kum|kunilingus|orgasim|orgasims|orgasm|orgasms|phonesex|phuk|phuq|porn|pussies|pussy|spunk|xxx)/i"; $spamwords = "/(viagra|phentermine|tramadol|adipex|advai|alprazolam|ambien|ambian|amoxicillin|antivert|blackjack|backgammon|texas|holdem|poker|carisoprodol|ciara|ciprofloxacin|debt|dating|porn)/i"; $bots = "/(Indy|Blaiz|Java|libwww-perl|Python|OutfoxBot|User-Agent|PycURL|AlphaServer)/i"; if (preg_match($bots, $_SERVER['HTTP_USER_AGENT'])) { exit("<h1>Error</h1>\nKnown spam bots are not allowed.<br /><br />"); } foreach ($_POST as $key => $value) { $value = trim($value); if (empty($value)) { exit("<h1>Error</h1>\nEmpty fields are not allowed. Please go back and fill in the form properly.<br /><br />"); } elseif (preg_match($exploits, $value)) { exit("<h1>Error</h1>\nExploits/malicious scripting attributes aren't allowed.<br /><br />"); } elseif (preg_match($profanity, $value) || preg_match($spamwords, $value)) { exit("<h1>Error</h1>\nThat kind of language is not allowed through our form.<br /><br />"); } $_POST[$key] = stripslashes(strip_tags($value)); } $name = escape_sql(CleanUp($_POST['name'])); $email = escape_sql(CleanUp($_POST['email'])); $reme = escape_sql(CleanUp($_POST['reme'])); if (is_array($reme)) { if($_POST['submit']){ foreach($_POST["id"] AS $key => $val) { $id = $val; $area = $_POST['reme'.$id.'']; $update = "UPDATE cards SET reme='$area' AND voted='$name' WHERE id='$id'"; } }} if(mysql_query($update, $connect)) { ?> <h1>Thank You!</h1> Thank you for sending in the release it form this helps me decide what upcoming decks to release. Please take what you see below <br /><br /> <center> <?php } else { ?> <h1>Error</h1> It looks like there was an error in processing your level up form. Send the information to <?php echo $tcgemail; ?> and we will send you your rewards ASAP. Thank you and sorry for the inconvenience. <?php } } } include("$footer"); ?>
  7. Hello, Well, basically what this code does is grab some links from a source code of a website and send them to an mp3 player. The big problem is on the get_link function, where i want to store the urls to an array. The section where im having problems is commented. Sorry for posting all this code but the functions are connected to each others. function getHost($db,$id){ if(isset($_GET['id'])){ $sql1 = "SELECT host FROM mixtape WHERE id=?"; $stm = $db->prepare($sql1); $stm->execute(array($id)); $row1 = $stm->fetch(PDO::FETCH_ASSOC); if($row1['host']=='host1'){ $sql2 = "SELECT link1 FROM faixa WHERE id_mixtape IN(SELECT id FROM mixtape WHERE id=?)"; $stm = $db->prepare($sql2); $stm->execute(array($id)); $rows_affected = $stm->rowCount(); $array=array(); if (count($rows_affected) > 0) { for($i=1; $i <= $rows_affected; $i++) { $row2 = $stm->fetch(PDO::FETCH_ASSOC); $url=$row2['link1']; get_Link($db,$url,$i,$rows_affected,$array); } } } } } function get_Link($db,$url,$pos,$rows_affect,$array){ $find = 'url:'; $reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/"; $data = file_get_contents($url); $data = explode("\n", $data); for ($line = 0; $line < count($data); $line++) { if (strpos($data[$line], $find) !== false) { $link = preg_replace($reg_exUrl,"", $data[$line]); $v[]=$link; } } if($pos!=$rows_affect-1){ $url="mylink.com/".$link."|"; }else{ $url="mylink.com/".$link."&amp"; } $array[$pos]=$url; var_dump($array); // Here says that are 3 values in the array. True if($pos==$rows_affect-1){ var_dump($array); // Here is only showing the last value in the array. Why? player($db,$array); } } function player($db,$array){ if(isset($_GET['id'])){ foreach($array as $i=>$item){ echo $item; } } }
  8. Hello. I designed a system a bit back and kinda cobbled it together. I was wondering if anyone could tell me of any security implications with the following setup: Usernames & passwords are stored on disk as a php array. A user enters their username and password into a form. On submit, the page include()s the username file & the checks to see if their username exists is the array. If it does, it checks that the password matches. If it does, a session variable key is assigned (username), with the username as the variable. As the user navigates the site, the session variables are maintained (session_start()), ensuring that a valid user is logged in. Is the above system relatively secure? Yes, it would be better over ssl and yes it would be vulnerable if a user managed to get read access to the files in the directory in which the usernames.php file is stored but it's on a hosting service which I believe to be secure and the uploader system ensures that uploads are stored in a separate directory with valid file extensions (.jpg etc). Thanks in advance for any advice. Toz
×
×
  • 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.