Search Results

Search found 45255 results on 1811 pages for 'php connect'.

Page 102/1811 | < Previous Page | 98 99 100 101 102 103 104 105 106 107 108 109  | Next Page >

  • Extremely basic PHP and Mysql

    - by fighella
    Background: I am more of a designer than a programmer, but have hacked templates for many open source CMS's (Drupal, Joomla, Wordpress) I want to start from scratch in regards to the relations of php and a mysql database. Lets assume I have a working database and php engine locally. What would be my first step to connecting to my database and creating a table... (im happy to be led to an appropriate tutorial...) Many of the tutorials I have seen start with basic php, but I would rather explore the connection between the db and the php.

    Read the article

  • Write permissions on uploaded files - Linux, Apache, PHP

    - by letseatfood
    I am working on a PHP script that transfers files using FTP functions. It has always worked on my production server (which is a hosting service). The development server I have just setup (I am a novice to servers) is Debian Lenny with Apache2, PHP5, and MySQL5. The file transfer works correctly, but once the file has been written to the server, it has permissions of 600. This makes it impossible for me to view the file (JPEG) in the web browser, as permission is denied. I have scoured the internet and even broken my server installation and reinstalled it trying to figure this out (which has been fun, nonetheless!). I know it is unwise to set 777 permissions on public accessible files, but even that will not solve the problem. The only thing that works is if I chmod 777 thefile.jpg after it has been transferred, which is not a working solution. I tried changing the owner of my site files to www-data per this post, but that also does not work. My user is mike, and it still does not work whether the owner of the files is mike or root. Would somebody point me in the right direction? Thanks! And, of course, let me know if I can clarify anything.

    Read the article

  • File based caching under PHP

    - by azatoth
    I've been using http://code.google.com/p/phpbrowscap/ for a project, and it usually works nice. But a few times it's cache, which is plain php-files (see http://code.google.com/p/phpbrowscap/source/browse/trunk/browscap/Browscap.php#372 et. al.), has been "zeroed", i.e. the whole cache file has become large blob of NULLs. Instead of trying to find out why the files become NULL, I though perhaps it might be better to change the caching strategy to something more resilient. So I do wonder if you has any good ideas what would be a good solution; I've been looking at http://www.jongales.com/blog/2009/02/18/simple-file-based-php-cache-class/ and http://www.phpclasses.org/package/313-PHP-Cache-arbitrary-data-in-files-.html and I also though of just saving an serialized array to the file instead of pure php as it's been doing now; But I'm uncertain what approach I should target here. I'm grateful for any insight into this area of technology, as I know it's complex from a performance point of view.

    Read the article

  • how to implement jquery php progress bar

    - by KittyYoung
    I have a multi-step form where the form on Step3 submits to Step4.php. Step4 is a results page, and it takes some time to load, so I wanted to try and implement a progress bar or a loading bar or something when the user clicks the step3 submit button before Step4.php actually loads. I would think I could do this with jquery? But, I'm not sure how. Is it possible to do this without having to use jquery to post the data to step4.php?

    Read the article

  • Newsletter send using AJAX to avoid PHP timeout

    - by simPod
    I need to send newsletters. I have already a PHP script that sends mass emails but it won't work for long as email database is growing because of PHP max script run time. So, to avoid it I came up with a solution: I would call my PHP script using AJAX in javascript and I will give it $_GET parameter with a count 20 so the script would sent only 20 emails. Than AJAX would receive success response, and call my script again and again till all emails are send. Is it possible? I'm asking because I have never seen such a solution so I'm wondering if it is real (It's kinda hard to implement this into my PHP framework so I'm asking experts here first) To sum it up here's a code skeleton: <script> var emailCount = 1000; //would get this from DB var runCount = 20; //number of emails sent in one cycle var from = 0; //start number function sendMail(){ if(from<emailCount){ jQuery.ajaxfunction({ path: 'script.php?from='+from+'&count='+runCount successFc: function(){ from+=runCount; sendMail(); } }) } } sendMail(); </script> So, are there any obstacles? Thanks a lot.

    Read the article

  • PHP specifying a fixed include source for scripts in different directories

    - by Extrakun
    I am currently doing unit testing, and use folders to organize my test cases. All cases pertaining to managing of user accounts, for example, go under \tests\accounts. Over time, there are more test cases, and I begin to seperate the cases by types, such as \tests\accounts\create, \tests\account\update and etc. However, one annoying problem is I have to specify the path to a set of common includes. I have to use includes like this: include_once ("../../../../autoload.php"); include_once ("../../../../init.php"); A test case in tests\accounts\ would require change to the include (one less directory level down). Is there anyway to have them somehow locating my two common includes? I understand I could set include paths within my PHP's configurations, or use server environment variables, but I would like to avoid such solutions as they make the application less portable and coupled with another layer which the programmer can't control (some web-host doesn't allow configuration of PHP's configuration settings, for example)

    Read the article

  • PHP Form Validation

    - by JM4
    This question will undoubtedly be difficult to answer and ask in a way that makes sense but I'll try my best: I have a form which uses PHP to display certain sections of the form such as: <?php if ($_SESSION['EnrType'] == "Individual") { display only form information for individual enrollment } ?> and <?php if ($_SESSION['Num_Enrs'] > 6) { display only form information for 7 total members enrollment } ?> In each form piece, unique information is collected about each enrollee but the basic criteria for each enrollee is the same, i.e. All enrollee's must use have a value in the FirstName field. Each field is named according to the enrollee number, i.e. Num1FirstName; Num2FirstName. I have a PHP validation script which is absolutely fantastic and am not looking to change it but the issue I am running into is duplication of the script in order to validate ALL fields in one swoop. On submission, all POSTED items are run through my validation script and based on the rules set return an error if they do not equal true. Sample code: if (isset($_POST['submit'])) { // import the validation library require("validation.php"); $rules = array(); // stores the validation rules //All Enrollee Rules $rules[] = "required,Num1FirstName,Num2FirstName,The First Name field is required."; The script above does the following, $rules[] ="REQUIREMENT,fieldname,error message" where requirement gives criteria (in this case, simply that a value is passed), fieldname is the name of the field being validated, and error message returns the error used. My Goal is to use the same formula above and have $rules[] run through ALL firstnames and return the error posted ONLY if they exist (i.e. dont check for member #7's first name if it doesnt exist on the screen). If I simply put a comma between the 'fieldnames' this only checks for the first, then second, and so on so this wont work. Any ideas?

    Read the article

  • Downloading a file from a PHP page in C#

    - by FoxyShadoww
    Okay, we have a PHP script that creates an download link from a file and we want to download that file via C#. This works fine with progress etc but when the PHP page gives an error the program downloads the error page and saves it as the requested file. Here is the code we have atm: PHP Code: <?php $path = 'upload/test.rar'; if (file_exists($path)) { $mm_type="application/octet-stream"; header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Type: " . $mm_type); header("Content-Length: " .(string)(filesize($path)) ); header('Content-Disposition: attachment; filename="'.basename($path).'"'); header("Content-Transfer-Encoding: binary\n"); readfile($path); exit(); } else { print 'Sorry, we could not find requested download file.'; } ?> C# Code: private void btnDownload_Click(object sender, EventArgs e) { string url = "http://***.com/download.php"; WebClient client = new WebClient(); client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted); client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged); client.DownloadFileAsync(new Uri(url), @"c:\temp\test.rar"); } private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e) { progressBar.Value = e.ProgressPercentage; } void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { MessageBox.Show(print); }

    Read the article

  • Identifying PHP unused variables (in Emacs)?

    - by Roberto Aloi
    Is it somehow possible to identify unused variables in a PHP file in Emacs? With other languages, this is possible by using tools such as flymake. I've already enabled Flymake to show syntax errors for my PHP files on the fly, but still it's frustrating that PHP logic errors are sometimes due to situations like: <?php $foo = whatever(); $bar = something($fo); ... Note the typo on $foo that will contribute to the developer's headache and to his exorbitant use of coffee.

    Read the article

  • print a picture from php

    - by robertdd
    how i can print a picture from php? when i acces the link: http://localhost/autovi/thumb.php?gsbxdsdc where the gsbxdsdc is the name of the image i have in my html this: <a href=""> <img src="http://localhost/autovi/thumb.php?gsbxdsdc" id="gsbxdsdc"> </a>

    Read the article

  • What is an example of MVC in PHP?

    - by waiwai933
    I'm trying to understand the MVC pattern. Here's what I think MV is: Model: <?php if($a == 2){ $variable = 'two'; } else{ $variable = 'not two'; } $this->output->addContent($variable); $this->output->displayContent(); ?> View: <?php class output{ private $content; public function addContent($var){ $this->content = 'The variable is '.$var; } public function displayContent(){ include 'header.php'; echo $content; include 'footer.php'; } } ?> Is this right? If so, what is the controller?

    Read the article

  • PHP mutual exclusion (mutex)

    - by Poni
    Read some texts about locking in PHP. They all, mainly, direct to http://php.net/manual/en/function.flock.php . This page talks about opening a file on the hard-disk!! Is it really so? I mean, this makes locking really expensive - it means each time I want to lock I'll have to access the hard-disk )= Can anymore comfort me with a delightful news?

    Read the article

  • Simaltaneous connections with PHP and SOAP?

    - by Dov
    I'm new to using SOAP and understanding the utmost basics of it. I create a client resource/connection, I then run some queries in a loop and I'm done. The issue I am having is when I increase the iterations of the loop, ie: from 100 to 1000, it seems to run out of memory and drops an internal server error. How could I possibly run either a) multiple simaltaneous connections or b) create a connection, 100 iterations, close connection, create connection.. etc. "a)" looks to be the better option but I have no clue as to how to get it up and running whilst keeping memory (I assume opening and closing connections) at a minimum. Thanks in advance! index.php <?php // set loops to 0 $loops = 0; // connection credentials and settings $location = 'https://theconsole.com/'; $wsdl = $location.'?wsdl'; $username = 'user'; $password = 'pass'; // include the console and client classes include "class_console.php"; include "class_client.php"; // create a client resource / connection $client = new Client($location, $wsdl, $username, $password); while ($loops <= 100) { $dostuff; } ?> class_console.php <?php class Console { // the connection resource private $connection = NULL; /** * When this object is instantiated a connection will be made to the console */ public function __construct($location, $wsdl, $username, $password, $proxyHost = NULL, $proxyPort = NULL) { if(is_null($proxyHost) || is_null($proxyPort)) $connection = new SoapClient($wsdl, array('login' => $username, 'password' => $password)); else $connection = new SoapClient($wsdl, array('login' => $username, 'password' => $password, 'proxy_host' => $proxyHost, 'proxy_port' => $proxyPort)); $connection->__setLocation($location); $this->connection = $connection; return $this->connection; } /** * Will print any type of data to screen, where supported by print_r * * @param $var - The data to print to screen * @return $this->connection - The connection resource **/ public function screen($var) { print '<pre>'; print_r($var); print '</pre>'; return $this->connection; } /** * Returns a server / connection resource * * @return $this->connection - The connection resource */ public function srv() { return $this->connection; } } ?>

    Read the article

  • php OOP function declarations

    - by kris
    I'm a big fan of OOP in php, but i feel like defining class methods gets disorganized so fast. I have a pretty good background in OOP in C++, and i am pretty comfortable with how it is handled there, and am curious if there are ways to do it similarly in php. To be more specific, here is what i mean. I like how in C++ you can define a class header (myclass.h) and then define the actual details of the functions in the implementation file (myclass.cc). Ive found that this can easily be replicated using interfaces in php, but i havent found a good solution for the following: I like to organize my code in C++ in different files based on how they are accessed, so for example, public methods that can be called outside of the class would be in 1 place, and private methods would be organized somewhere else - this is personal preference. Ive tried to define class methods in php like: private function MyPHPClass::myFunction(){ } when the definition isnt directly inside the class block( { } ), but i havent had any success doing this. Ive been through all of the pages on php.net, but couldnt find anything like this. Im assuming that there is no support for something like this, but thought i would ask anyway. thanks

    Read the article

  • Advice/suggestions for my first project PHP Classes

    - by Philip
    Hi guys, Any advice is welcome! I have a very limited understanding of php classes but below is my starting point for the route I would like to take. The code is a reflection of what I see in my head and how I would like to go about business. Does my code even look ok, or am I way off base? What are your thoughts, how would you go about achieving such a task as form-validate-insertquery-sendmail-return messages and errors? Please try and keep your answers simple enough for me to digest as for me its about understanding whats going on and not just a copy/paste job. Kindest regards, Phil. Note: This is a base structure only, no complete code added. <?php //======================================= //class.logging.php //======================================== class logging { public $data = array(); public $errors = array(); function __construct() { array_pop($_POST); $this->data =($this->_logging)? is_isset(filterStr($_POST) : ''; foreach($this->data as $key=> $value) { $this->data[$key] = $value; } //print_r($this->data); de-bugging } public function is_isset($str) { if(isset($str)) ? true: false; } public function filterStr($str) { return preg_match(do somthing, $str); } public function validate_post() { try { if(!is_numeric($data['cardID'])) ? throw new Exception('CardID must be numeric!') : continue; } catch (Exception $e) { return $errors = $e->getCode(); } } public function showErrors() { foreach($errors as $error => $err) { print('<div class="notok"></div><br />'); } } public function insertQ() { $query = ""; } } //======================================= //Usercp.php //======================================== if(isset($_GET['mode'])) { $mode = $_GET['mode']; } else { $mode = 'usercp'; } switch($mode) { case 'usercp': echo 'Welcome to the User Control Panel'; break; case 'logging': require_once 'class.logging.php'; $logger = new logging(); if(isset($_POST['submit']) { if($logger->validate_post === true) { $logger->insertQ(); require_once '/scripts/PHPMailer/class.phpmailer.php'; $mailer = new PHPMailer(); $mailer->PHPMailer(); } else { echo ''.$logger->showErrors.''; } } else { echo ' <form action="'.$_SERVER['PHP_SELF'].'?mode=logging" method="post"> </form> '; } break; case 'user_logout': // do somthing break; case 'user_settings': // do somthing break; ?>

    Read the article

  • php: save me from dissapointment

    - by Syom
    i'm being dissapointed in programming when some issues can't be placed in my mind. i have file, which starts <?php session_start();?>, and it returns an error Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp2\htdocs\index.php:1) in C:\xampp2\htdocs\index.php on line 3 and now take a look at the moment, i can't anderstand anyway when i copy the all content of my file into another file, it start working. can somebody explain how can it happen. thanks

    Read the article

  • PHP script to process NSURLRequest from iphone

    - by tech74
    Hi, i will be sending a POST request to login.php on my server from an iphone app over HTTPS. The POST is created using NSMutableURLRequest. Is there an example of a PHP script to process this POST on my server. The POST isn't sent as a form as such , anyway not that i think it is. Not sure how NSMutableURLRequest formats this. I just need to know how to access the POST data on the server with the php script. All the examples ive seen regarding php scripts processing POSTS seem to be do with forms. So how do i process this? Any links etc most welcome. Thanks

    Read the article

  • Troubles with DateTime and PHP 5.2

    - by Nate Wagar
    I'm attempting to use the PHP DateTime class on a server with PHP 5.2.6, with a test server running PHP 5.3. Here is the code: <?php try { $dt = new DateTime('2009-10-08'); $dt->setDate(2009,10,8); print_r($dt); }catch (Exception $e) { echo $e->getMessage(); } On the test server, things work flawlessly, this is what prints: DateTime Object ( [date] => 2009-10-08 00:00:00 [timezone_type] => 3 [timezone] => America/New_York ) On the server I need to use it on, however, this is what prints: DateTime Object ( ) Removing the setDate makes no difference whatsoever. Any ideas why this might be happening? Thanks!

    Read the article

  • INET_ATON() and INET_NTOA() in PHP?

    - by blerh
    I want to store IP addresses in my database, but I also need to use them throughout my application. I read about using INET_ATON() and INET_NTOA() in my MySQL queries to get a 32-bit unsigned integer out of an IP address, which is exactly what I want as it will make searching through the database faster than using char(15). The thing is, I can't find a function that does the same sort of thing in PHP. The only thing I came across is: http://php.net/manual/en/function.ip2long.php So I tested it: $ip = $_SERVER['REMOTE_ADDR']; echo ip2long($ip); And it outputs nothing. In the example they gave it seems to work, but then again I'm not exactly sure if ip2long() does the same thing as INET_ATON(). Does someone know a PHP function that will do this? Or even a completely new solution to storing an IP address in a database? Thanks.

    Read the article

< Previous Page | 98 99 100 101 102 103 104 105 106 107 108 109  | Next Page >