php

Create an 'unconnected' SQLite instance

Ive just discovered the convenience of having SQLite at my disposal. However, the convenience factor is causing a small problem for me and the way I've set up my database connection objects. In order to provide some semblance of database neutrality and abstraction, I've created a DatabaseUtil.php factory class - the main method, getDBC...

Where am I going wrong? SQL Query

$foot = mysql_query("SELECT count(*) FROM tblQA WHERE intResponseID = '' AND cCategory = 'Football' as qcount, (SELECT max(dPostDateTime) FROM tblQA WHERE intResponseID = '' ...

What would be the best way to verify a user uploaded file?

After a file has been uploaded to the tmp folder, for example a pdf file, would php fileinfo mime check be enough to verify that the file is indeed a pdf file and is not infected? How do you verify that a user uploaded file has no virus? so that I could let users download it? My scenario is this: A user uploads a pdf file, I then let...

000webhost sql server problem

I cannot figure out how to connect to the server with php 000webhost doesn't have localhost as their host name I tried to get it by doing one variable but it did not work when I tried to connect to the server with the code provided well I am writing an if statement that says if my site cannot connect then "die();" with the code provi...

how to replace string from given offset ?

I need only one replacement of a string within a string, but since string that am intend to replace is repeated in the haystack I need to precise start pointer and how many times replacement should be done. I did not found any mention of start offstet if php's string replace functions. ...

Badges system using asynchronous php call

I'd like to implement a badge/reputation system on one of my site. When a user performs an action an event will be raised (ex: QUESTION_PUBLISHED) so that the system can check if a new badge can be awarded to the user. The logic for some of the badges is quite complex and would require slow sql queries. Instead of using cron jobs I was ...

PHP/Javascript: Tell two computers apart from same network

I'm developing a site where you are not allowed to login on multiple accounts on one computer, but I do not know how to do this. The method has to be: Cross-platform (can be used on Windows/Mac/Linux clients). Browser independent. This is to avoid some users exploiting multiple users to gain unfair advantages, while still allowing tw...

Alternative to TCPDF for large-volume pdf generation

I generate pdf documents with TCPDF. It's fairly easy to setup and very good for creating pdf files with <10 pages. I can generate 50 pages long PDF files within the 60 seconds default php timeout and can generate upto 200 pages when the timeout is set to 300 (SET_TIME_LIMIT(300)). I have also allocated 256 mb memory in the PHP ini....

$_Files[] array only showing first file uploaded

I currently have a form with a single file upload input on it. the original form input I've tried <input type="file" name="userFile[]" /> and <input type="file" name="userFile1" /> I also have a link to generate more input fields using If have tried methods of: a) counter = 1; function addInput(){ counter ++; $('#divName').app...

PHP preg_replace not working

Hello there. okay so i got a script that removes "_" and replaces it with a space " " and it does not work i even used ereg_replace and eregi_replace none worked yet it works backwards( " ","_") thanks a lot here is the script: $namefixed = preg_replace("/_/", " ", $name); and even $namefixed = preg_replace("_", " ", $name); ...

$_SERVER question!?

Can anyone explain how I can use $_SERVER['REQUEST_URI'] How can I make it required like: In order to access this page, you have to come from THIS page (both are internal)? I thought $_SERVER can do this for me, and found the example above in php.net. How can I make use from it? Thanks ...

Method return status: bool, string, const... (PHP)

Hi all! This question: http://stackoverflow.com/questions/356248/best-way-to-return-status-flag-and-message-from-a-method-in-java is similar to mine, however I would do it in PHP, not Java (which could make a slight difference here). The problem: There's a method that can have either a successful outcome (this may change to be more su...

Code Igniter Load Database seem to stop process thread

I've just set up a simple PHP Code Igniter project on a Windows 7 box, IIS 7, Fast CGI, no modules. when I load up database in one of the function of a Model class by doing such this->load->database() the thread seem to stop on that particular line. None of the subsequent operations are done. class Account_model extends Model { var ...

PHP - String manipulation remove spcial characters and replace spaces

I am getting strings from a database and then using the strings to build a URL. My issue is, some of the strings will have characters like < > & { } * general special characters, but the string may also have strings in. How would I replace the spaces with dashes and totally remove and special characters from the strings? ...

mysqli php extend

Hi guys, i was wondering if you could point me in the right direction. Im extending the mysqli class but cant seem to call the error function.. <?php class mysqli_ls extends mysqli { private $activeConnection = 0; private $linkArr = array(); private $queryArr = array(); private $errorArr = array(); public function _...

php remove from string

Nice quick one for you guys, hope you can help. After a dodgy CMS I created a while ago, my database is full of product 'names' that have either 1, 2 or 3 spaces before the actual name. This is causing me havoc now and I'm wondering if there's a function that will let me remove these pesky spaces in PHP instead of having to update the d...

Php syntax problem

<input type="radio" name="ques1" value="op4">Jingles<br> just a part of the code..... when i am checking this... iam doing this as $selected=$_POST['ques1']; now when i am doing this with for loop.... for($i=0;$i<...;$i++) $selected=$_POST['ques'.{$i+1}]; NEW SYSNTAX ADDED............................... $sql='UPDATE Reg_Stud SE...

PHP & Javascript: Image file description properties (Summary tab)

Image files come with description properties like title, subject and keyword (summary tab). How do I "get" these properties in PHP? is there a function that allows me to the same in Javascript? ...

php login: issue with header

I'm trying to make a login page using php, but when I use header() to redirect to another page, my user/pass check on my database somehow fails. Am I doing something wrong? Also, I know I'm missing security guards, I'm implementing in steps since I'm still rather new to PHP. But some tips and suggestions would be appreciated! $dbc = my...

CakePHP - How I could receive related object?

I am trying get all commments relateed to my current post, I am doing it as following: $this->Post->Comment->find('all', array('conditions' => array('post_id' => $id))); but in my opinion, it is a little uncomfortably. Why I should give post_id? Isn't it obvious that I want Comment related to current Post? ...