Search Results

Search found 42698 results on 1708 pages for 'php in array'.

Page 116/1708 | < Previous Page | 112 113 114 115 116 117 118 119 120 121 122 123  | Next Page >

  • Problem with comparing value with array values

    - by Java starter
    This code is what I use now. But it does not work when I try to use an array to compare values. If anybody has any idea of why, please respond. <html> <head> <script type-'text/javascript'> function hovedFunksjon() { //alert("test av funksjon fungerte"); //alert(passordLager); window.open("index10.html","Window1","menubar=no,width=430,height=360,toolbar=no"); } function inArray(array, value) { for (var i = 0; i < array.length; i++) { if (array[i] == value) return true; } return false; } function spørOmPassord() { var passordLager = ["pass0","pass1","pass2"]; window.passordInput = prompt("password");//Ved å bruke "window." skaper man en global variabel //if (passordInput == passordLager[0] || passordLager[1] || passordLager[2]) if (inArray(passordLager,passorInput) ) { hovedFunksjon(); } else { alert("Feil passord"); //href="javascript:self.close()">close window } } function changeBackgroundColor() { //document.bgColor="#CC9900"; //document.bgColor="YELLOW" document.bgColor="BLACK" } </script> </head> <body> <script type-'text/javascript'> changeBackgroundColor(); </script> <div align="center"> <form> <input type = "button" value = "Logg inn" onclick="spørOmPassord()"> </form> </div> </body> </html>

    Read the article

  • PHP unlink OR rewrite own/current file by itself

    - by Email
    Hi Task: Cut or erase a file after first walk-through. i have an install file called "index.php" which creates another php file. <? /* here some code*/ $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = "<?php \n echo 'hallo, *very very long text*'; \n ?>"; fwrite($fh, $stringData); /*herecut"/ /*here some code */ after the creation of the new file this file is called and i intent to erase the filecreation call since it is very long and only needed on first install. i therefor add to the above code echo 'hallo, *very very long text*'; \n ***$new= file_get_contents('index.php'); \n $findme = 'habanot'; $pos = strpos($new, $findme); if ($pos === false) { $marker='herecut';\n $new=strstr($new,$marker);\n $new='<?php \n /*habanot*/\n'.$new;\n $fh = fopen('index.php', 'w') or die 'cant open file'); $stringData = $new; fwrite($fh, $stringData); fclose($fh);*** ?>"; fwrite($fh, $stringData);]} Isnt there an easier way or a function to modify the current file or even "self destroy" a file after first call? Regards

    Read the article

  • PHP While loop seperating unique categories from multiple 'Joined' tables

    - by Hob
    I'm pretty new to Joins so hope this all makes sense. I'm joining 4 tables and want to create a while loop that spits out results nested under different categories. My Tables categories id | category_name pages id | page_name | category *page_content* id | page_id | image_id images id | thumb_path My current SQL join <?php $all_photos = mysql_query(" SELECT * FROM categories JOIN pages ON pages.category = categories.id JOIN image_pages ON image_pages.page_id = pages.id JOIN images ON images.id = image_pages.image_id ");?> The result I want from a while loop I would like to get something like this.... Category 1 page 1 Image 1, image 2, image 3 page 2 Image 2, image 4 Category 2 page 3 image 1 page 4 image 1, image 2, image 3 I hope that makes sense. Each image can fall under multiple pages and each page can fall under multiple categories. at the moment I have 2 solutions, one which lists each category several times according to the the amount of pages inside them: eg. category 1, page 1, image 1 - category 1, page 1, image 2 etc One that uses a while loop inside another while loop inside another while loop, resulting in 3 sql queries. <?php while($all_page = mysql_fetch_array($all_pages)) { ?> <p><?=$all_page['page_name']?></p> <?php $all_images = mysql_query("SELECT * FROM images JOIN image_pages ON image_pages.page_id = " . $all_page['id'] . " AND image_pages.image_id = images.id"); ?> <div class="admin-images-block clearfix"> <?php while($all_image = mysql_fetch_array($all_images)) { ?> <img src="<?=$all_image['thumb_path']?>" alt="<?=$all_image['title']?>"/> <?php } ?> </div> <?php } } ?

    Read the article

  • PHP class_exists always returns true

    - by Ali
    I have a PHP class that needs some pre-defined globals before the file is included: File: includes/Product.inc.php if (class_exists('Product')) { return; } // This class requires some predefined globals if ( !isset($gLogger) || !isset($db) || !isset($glob) ) { return; } class Product { ... } The above is included in other PHP files that need to use Product using require_once. Anyone who wants to use Product must however ensure those globals are available, at least that's the idea. I recently debugged an issue in a function within the Product class which was caused because $gLogger was null. The code requiring the above Product.inc.php had not bothered to create the $gLogger. So The question is how was this class ever included if $gLogger was null? I tried to debug the code (xdebug in NetBeans), put a breakpoint at the start of Product.inc.php to find out and every time it came to the if (class_exists('Product')) clause it would simply step in and return thus never getting to the global checks. So how was it ever included the first time? This is PHP 5.1+ running under MAMP (Apache/MySQL). I don't have any auto loaders defined.

    Read the article

  • Pass a variable from the source file to an included file in PHP

    - by Alpha1
    For my website I want to store the general format of the site in a single PHP file in a single location, and each of the different pages content in the local location of the page. I then want to pass the title and content address to the included file via a variable. However I can't get the included format file to read the variables storing the title and content data. AKA, the called file for the individual page would be: <?php $title = 'Some Title'; $source_file = 'content.php'; readfile('http:...../format.php'); ?> The format file would be: <html> ... <title> <?php echo $title; ?> </title> ... <?php include($source_file); ?> ... I recall reading somewhere I need to include something to get the variables at the start of the format file, however I can't remember what it is or find where I found that information.

    Read the article

  • PHP Array saved to Text file

    - by coffeemonitor
    I've saved a response from an outside server to a text file, so I don't need to keep running connection requests. Instead, perhaps I can use the text file for my manipulation purposes, until I'm read for re-connecting again. (also, my connection requests are limited to this outside server) Here is what I've saved to a text file: records.txt Array ( [0] => stdClass Object ( [id] => 552 [date_created] => 2012-02-23 10:30:56 [date_modified] => 2012-03-09 18:55:26 [date_deleted] => 2012-03-09 18:55:26 [first_name] => Test [middle_name] => [last_name] => Test [home_phone] => (123) 123-1234 [email] => [email protected] ) [1] => stdClass Object ( [id] => 553 [date_created] => 2012-02-23 10:30:56 [date_modified] => 2012-03-09 18:55:26 [date_deleted] => 2012-03-09 18:55:26 [first_name] => Test [middle_name] => [last_name] => Test [home_phone] => (325) 558-1234 [email] => [email protected] ) ) There's actually more in the Array, but I'm sure 2 are fine. Since this is a text file, and I want to pretend this is the actual outside server (sending me the same info), how do I make it a real array again? I know I need to open the file first: <?php $fp = fopen('records.txt', "r"); // open the file $theData = fread($fh, filesize('records.txt')); fclose($fh); echo $theData; ?> So far $theData is a string value. Is there a way to convert it back to the Array it originally came in as?

    Read the article

  • How to avoid notice in php when one of the conditions is not true

    - by user225269
    I've notice that when one of the two conditions in a php if statement is not true. You get an undefined index notice for the statement that is not true. And the result in my case is a distorted web page. For example, this code: <?php session_start(); if (!isset($_SESSION['loginAdmin']) && ($_SESSION['loginAdmin'] != '')) { header ("Location: loginam.php"); } else { include('head2.php'); } if (!isset($_SESSION['login']) && ($_SESSION['login'] != '')) { header ("Location: login.php"); } else { include('head3.php'); } ?> If one of the if statements is not true. The one that is not true will give you a notice that it is undefined. In my case it says that the session 'login' is not defined. If session 'LoginAdmin' is used. What can you recommend that I would do in order to avoid these undefined index notice.

    Read the article

  • JQuery to PHP function and back Ajaxed

    - by Xaris
    Hi all, i have a set of php function that i want to call on different events mostly onclick with jquery async (ajax). The first function is called on load $(document).ready(function() { $("#div2").hide('slow'); $("#div1").empty().html('<img src="ajax-loader.gif" />'); $.ajax( { type: "POST", url: "WebFunctions.php", data: {'func':'1'}, success: function(html) { $("#div1").show('slow').html(html) } }); The Data: {'func':'1'} -- is a switch statement on the php side switch($_POST['func']) { case '1': getParents(); break; case '2': getChilds(params); break; case '3': getChildObjects(params); break; default: } "This functions are calls to a soap server" <-- irrelevant. So when that function finishes i get an array which contains IDs and Names. I echo the names but i want the ID for reference so when i click on the echoed name i can call an other php function with parameter the ID of the name... How do i get rid of the switch statement?? How do i call properly php functions and pass params to it??? How can i save this IDs so when i click on an item with that id an other php function is called?? Plz feel free to ask any question, any answer is welcome :)

    Read the article

  • comparing value with array value problem Javascript

    - by Java starter
    This code is what I use now, it dos not work when I trie to use an array to compate values. If anybody has any idea of why, please respond. <html> <head> <script type-'text/javascript'> function hovedFunksjon() { //alert("test av funksjon fungerte"); //alert(passordLager); window.open("index10.html","Window1","menubar=no,width=430,height=360,toolbar=no"); } function inArray(array, value) { for (var i = 0; i < array.length; i++) { if (array[i] == value) return true; } return false; } function spørOmPassord() { var passordLager = ["pass0","pass1","pass2"]; window.passordInput = prompt("password");//Ved å bruke "window." skaper man en global variabel //if (passordInput == passordLager[0] || passordLager[1] || passordLager[2]) if (inArray(passordLager,passorInput) ) { hovedFunksjon(); } else { alert("Feil passord"); //href="javascript:self.close()">close window } } function changeBackgroundColor() { //document.bgColor="#CC9900"; //document.bgColor="YELLOW" document.bgColor="BLACK" } </script> </head> <body> <script type-'text/javascript'> changeBackgroundColor(); </script> <div align="center"> <form> <input type = "button" value = "Logg inn" onclick="spørOmPassord()"> </form> </div> </body> </html>

    Read the article

  • Unable to Get values from Web Form to a PHP Class to Display

    - by kentrenholm
    I am having troubles getting the value from my variables submitted via a web form using a PHP class file. Here is my structure of the web page: Order Form Page Process.php Page Book.php Page I can easily get the user data entered (on Order Form Page), process, and display it on the Process.php page. The issue is that I must create a Book class and print the details of the data using the Book class. I have an empty constructor printing out "created" so I know my constructor is being called. I also am able to print the word "title" so I know I can print to the screen by using the Book class. My issue is that I can't get values in my variables in the Book class. Here is my variable declaration: private $title; Here is my printDetails function: public function printDetails () { echo "Title: " . $this->title . "<br />"; } Here is my new instance of the book class: $bookNow = new book; Here are my get and set functions: function __getTitle($title) { return $this->$title; } function __setTitle($title,$value) { $this->$title = $value; } I do have four other variables that I'm looking to display as well. Each of those have their own variable declaration, a line in printDetails, and their own setter and getter. Lastly, I also have a call to the Book class in my process PHP. It looks like this: function __autoload($book) { include $book . '.php'; } $bookNow = new book(); Any help, much appreciated. It must be something so very small (I'm hoping).

    Read the article

  • How to load data on option box in php

    - by user225269
    I'm having trouble loading the mysql data on the html form option box using php. Here's my code: <?php $con = mysql_connect("localhost","myuname","mypassword"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("school", $con); $idnum= mysql_real_escape_string($_POST['idnum']); $result = mysql_query("SELECT * FROM student WHERE IDNO='$idnum'"); ?> <?php while ( $row = mysql_fetch_array($result) ) { ?> <tr> <td width="30" height="35"><font size="2">*I D Number:</td> <td width="30"><input name="idnum" type="text" maxlength="5" value="<?php echo $row["IDNO"]; ?>" readonly="readonly"></td> </tr> My problem is loading it here: <td><font size="2">Gender</td> <td> <select name="gender" id="gender"> <font size="2"> <option value="<?php echo $line['IDNO']; ?> "><?php $line['GENDER'] ; ?></option> </select></td></td> The table looks like this: IDNO | GENDER 123 | M 321 | F What am I supposed to do?To load the exact gender corresponding to the IDNO?

    Read the article

  • Include php code within echo from a random text

    - by lisa
    I want to display a php code at random and so for I have <?php // load the file that contain thecode $adfile = "code.txt"; $ads = array(); // one line per code $fh = fopen($adfile, "r"); while(!feof($fh)) { $line = fgets($fh, 10240); $line = trim($line); if($line != "") { $ads[] = $line; } } // randomly pick an code $num = count($ads); $idx = rand(0, $num-1); echo $ads[$idx]; ?> The code.txt has lines like <?php print insert_proplayer( array( "width" => "600", "height" => "400" ), "http://www.youtube.com/watch?v=xnPCpCVepCg"); ?> Proplayer is a wordpress plugin that displays a video. The codes in code.txt work well, but not when I use the pick line from code.txt. Instead of the full php line I get: "width" => "600", "height" => "400" ), "http://www.youtube.com/watch?v=xnPCpCVepCg"); ?> How can I make the echo show the php code, rather than a txt version of the php code?

    Read the article

  • creating new instance fails PHP

    - by as3isolib
    I am relatively new to PHP and having some decent success however I am running into this issue: If I try to create a new instance of the class GenericEntryVO, I get a 500 error with little to no helpful error information. However, if I use a generic object as the result, I get no errors. I'd like to be able to cast this object as a GenericEntryVO as I am using AMFPHP to communicate serialize data with a Flex client. I've read a few different ways to create constructors in PHP but the typical 'public function Foo()' for a class Foo was recommended for PHP 5.4.4 //in my EntryService.php class public function getEntryByID($id) { $link = mysqli_connect("localhost", "root", "root", "BabyTrackingAppDB"); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $query = "SELECT * FROM Entries WHERE id = '$id' LIMIT 1"; if ($result = mysqli_query($link, $query)) { // $entry = new GenericEntryVO(); this is where the problem lies! while ($row = mysqli_fetch_row($result)) { $entry->id = $row[0]; $entry->entryType = $row[1]; $entry->title = $row[2]; $entry->description = $row[3]; $entry->value = $row[4]; $entry->created = $row[5]; $entry->updated = $row[6]; } } mysqli_free_result($result); mysqli_close($link); return $entry; } //my GenericEntryVO.php class <?php class GenericEntryVO { public function __construct() { } public $id; public $title; public $entryType; public $description; public $value; public $created; public $updated; // public $properties; } ?>

    Read the article

  • php search database for row

    - by Brenden Morley
    Okay I got code the code to pull data based on a users account number well here is what im using (And yes I know it isnt safe now that is the reason for my post) <?php include('config.php'); $user_info = fetch_user_info($_GET['AccountNumber']); ?> <html> <body> <div> <?php if ($user_info === false){ $Output = 'http://www.MyDomain.Com/'; echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$Output.'">'; }else{ ?> <center> <title><?php echo $user_info['FirstName'], ' ', $user_info['LastName'], ' - ', $user_info['City'], ', ', $user_info['State']; ?> - Name of site</title> So basically what this code is allowing me to do is have a file called Profile.php And when a user visits this this page it will return the data Like this http://MyDomain.com/Profile.php?AccountNumber=50b9c965b7c3b How can I do this securely cause right now its using a get method really unsafe to retive the account number from the url bar.

    Read the article

  • check array against each other, to determine response

    - by Johnny
    So, I have an array that has 6 variables in it that I need to check against each other.. to determine what to return to the script calling the function.. All fields are of the datetime type from the database they are derived from. the fields: in1 out1 in2 out2 in3 out3 Array: Array( 'in1' => '2012-04-02 10:00:00), `out1` => '2012-04-02 14:00:00`, `in2` => '2012-04-02 14:30:00`, `out2` => '2012-04-02 18:00:00`, `in3` => NULL, `out3` => NULL ) the response: clocked_in or clocked_out What I need to figure out is, the best way to determine if the user is clocked in or clocked out by checking against this array.. so, if in1, out1 and in2 are not NULL then the user would be clocked in.. if in1 is not NULL but out1 is NULL then the user would be clocked out, etc.. Anyone have any ideas on the easiest way to achieve this without too many if statements? [WHAT WORKED] for ($i=1; $i <= 3; $i++) { if ($entities["in$i"] != NULL) { $ents = "clocked_in"; if ($entities["out$i"] != NULL) { $ents = "clocked_out"; } if ($entities["out3"] != NULL) { $ents = "day_done"; } } }

    Read the article

  • php session_start() error

    - by tooepic
    Hi, i've used a sample found on online and applied it to my code: <?php session_start(); if (isset($_REQUEST["email"])) { $_SESSION["name"] = true; $host = $_SERVER["HTTP_HOST"]; $path = dirname($_SERVER["PHP_SELF"]); $sid = session_name() . "=" . session_id(); header("Location: index.php?$sid"); exit; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> ... ... and rest of the html code When I open this page, I got an error: Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /data/server/user/directory/sub-directory/login.php:1) in /data/server/user/directory/sub-directory/login.php on line 2 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /data/server/user/directory/sub-directory/login.php:1) in /data/server/user/directory/sub-directory/login.php on line 2 I looked around to resolve this issue and saw few posts about this in this site also, but I just can't get a good grip on this...can't find the answer. Please help. Thanks.

    Read the article

  • VB 2008 - Index was outside the bounds of the array

    - by Jan
    Hey guys I'm having a problem while reading a config.cfg file of my program. I can read the 23. char of the file but I can't read the 24. char (last char in file). This is the code: Dim CFGReader2 As System.IO.StreamReader CFGReader2 = _ My.Computer.FileSystem.OpenTextFileReader(CurDir() & "\Config.cfg") Dim Server(2) As String Server(0) = CFGReader2.ReadToEnd.Chars(23)//This part works If Server(0) = 0 Then Server(1) = CFGReader2.ReadToEnd.Chars(24)//This part results in "Index was outside the bounds of the array". ElseIf Server(0) = 1 Then Server(2) = CFGReader2.ReadToEnd.Chars(24)//This part results in "Index was outside the bounds of the array". Server(1) = 10 + Server(2) ElseIf Server(0) = 2 Then Server(2) = CFGReader2.ReadToEnd.Chars(24)//This part results in "Index was outside the bounds of the array". Server(1) = 20 + Server(2) ElseIf Server(0) = 3 Then Server(2) = CFGReader2.ReadToEnd.Chars(24)//This part results in "Index was outside the bounds of the array". Server(1) = 30 + Server(2) End If And this is the file: Language = 2 Server = 11 Thanks for the answer! Frosty

    Read the article

  • Question about array subscripting in C#

    - by Michael J
    Back in the old days of C, one could use array subscripting to address storage in very useful ways. For example, one could declare an array as such. This array represents an EEPROM image with 8 bit words. BYTE eepromImage[1024] = { ... }; And later refer to that array as if it were really multi-dimensional storage BYTE mpuImage[2][512] = eepromImage; I'm sure I have the syntax wrong, but I hope you get the idea. Anyway, this projected a two dimension image of what is really single dimensional storage. The two dimensional projection represents the EEPROM image when loaded into the memory of an MPU with 16 bit words. In C one could reference the storage multi-dimensionaly and change values and the changed values would show up in the real (single dimension) storage almost as if by magic. Is it possible to do this same thing using C#? Our current solution uses multiple arrays and event handlers to keep things synchronized. This kind of works but it is additional complexity that we would like to avoid if there is a better way.

    Read the article

  • Strange bug with PHP on Windows 7

    - by chessweb
    This is the configuration: Windows 7 Home Premium, XAMPP 1.7.3 (Apache 2.2.14 , PHP 5.3.1), Firefox 3.6 This is the PHP-code in a file named 'test.php' in htdocs: <?php echo('04556-8978765'); ?> On http://localhost/test.php I would expect to see the string 04556-8978765 in the browser. This is not what happens, though. The string appears for a short time and then it disappears altogether. Firebug shows an empty body-tag. However, when I look at page source, the string is there alright. When I change the string in the echo-statement to e.g. 4556-8978765, everything is fine. Internet Explorer 8 does not show this strange behavior. I could not reproduce this with the same Apache/PHP/Firefox configuration on Windows XP. '04556-8978765' is by no means unique. The couple '02065-96047' and '02065-9604' behave exactly the same. Can anybody reproduce this and offer an explanation as to what is going on? PS: If you can not see the string '04556-8978765' in the echo-statement above, look at this post with IE8.

    Read the article

  • wpautop() - when shortcode attributes are on new lines -breaks args array

    - by Luca
    I have a custom shortcode tag with a few attributes, and I would like to be able to display its attributes on new lines - to make it more readable to content editors: [component attr1 ="value1" attr2 ="value of the second one" attr3 ="another" attr4 ="value" ... attrN ="valueN"] The reason behind this requirement is that a few attributes might be quite verbose in content. Unfortunately, wpautop() adds some nasty extra markup that breaks the args array like this (using php print_r($args)): Array ( [0] => attr1 [1] => ="value1" /> [3] => attr2 = [4] => "value [5] => of [6] => the [7] => second [8] => one" /> [10] => "" //...and more like this) I've tried with the attributes inline: [component attr1 ="value1" attr2 ="value of the second one" ="value"... attrN ="valueN"] and the output is as expected: Array ( [attr1] => value1 [attr2] => value of the second one [attr3] => //...and so on) is there any way to have the attributes intented and avoid that extra markup that breaks the $args array?

    Read the article

  • PHP: Adding arrays together

    - by Svish
    Could someone help me explain this? I have two snippets of code, one works as I expect, but the other does not. This works $a = array('a' => 1, 'b' => 2); $b = array('c' => 3); $c = $a + $b; print_r($c); // Output Array ( [a] => 1 [b] => 2 [c] => 3 ) This does not $a = array('a', 'b'); $b = array('c'); $c = $a + $b; print_r($c); // Output Array ( [a] => 1 [b] => 2 ) What is going on here?? Why doesn't the second version also add the two arrays together? What have I misunderstood? What should I be doing instead? Or is it a bug in PHP?

    Read the article

  • Session in php are not enough clear to me

    - by Lulzim
    I find sessions in php kind of confusing, can anybody of you explain those to me. I have an example which is not working in my case: I register sessions this way, would you please tell me is this the right way of registering sessions //this is the page from where i register myusername in sessions if($count==1){ session_start(); $_SESSION['myusername'] = $_POST['myusername']; include("enterpincover.php"); } else { echo "Wrong Pin"; } here i check first whether the username is registered in sessions in oder to open his account , otherwise open again login. It works, if user is not loged in, it will show login page which is right, if user is loged it shows welcome message but not the Welcome the name of the user as I want. for ex: Welcome David <?php session_start(); if(isset($_SESSION['myusername'])) { echo 'Welcome '.$_SESSION['myusername']; } else { include("leftmodules.php"); include("rightmodules.php"); include("login.php"); } ?>

    Read the article

< Previous Page | 112 113 114 115 116 117 118 119 120 121 122 123  | Next Page >