php

Function to check if a string is backslashed for mysql

Since there is no function to check whether a string is escaped before entering it to the db, how can I do this with regex? $string = 'some" string'; if(!preg_match('//',$string)) { $string = mysqli_real_escape_string($string); } php manual: mysqli_real_escape_string backslashes characters encoded NUL (ASCII 0), \n, \r, \, ', ...

Not writing to file, but no errors PHP

I am trying to write data from form inputs to a text file using PHP. The file seems to load correctly, but does not write the data. I have echoed the input values directly before trying to write to ensure they are not empty. The text file is in the same directory as the php file. I orginally got the error "Warning: fwrite(): supplied...

PHP array manipulation

i have this array: Array ( 0 => "3_some val", 1 => "1_some other val", 2 => "0_val", 3 => "2_value", 4 => "4_other value" ) considering the above array, is there a way to do from that an array like this? Array ( 0 => "val", 1 => "some other val", 2 => "value", ...

How to record voice files using PHP, FLASH

Hi I am developing an application where I need to record voice(for those who does not have a webcam so they can use only microphone to record voice) or video(those who have a a webcam - like laptop or external) files and save them on server, thereafter save the file name and logged in users id on database for later access. I know I ne...

Passing ID with CodeIgniter

Busy building my first web application in CodeIgniter and wanted to work out the best way of gathering ID in my Admin function for Edit, Delete statements. I realised I can use any of the following: Pass the ID through the controller. Collect the ID from the URI segment. Collect the ID from a hidden form field. Which is the best bas...

naming convention for methods that return boolean or indicate binary state?

Can someone point me to a guide for naming methods that return boolean or indicate a boolean state? I'm talking about things I've named like recordsExist(), issetVariable(), questionPrompted(), commentAsked(). Thinking this over, I think that two basic problems I'm looking at are 1: Has a user-interface event happened? and 2: do[es] dat...

Symfony homepage not displaying image

I created a Symfony project and I can access it from a web browser but it doesn't display any images. I get this instead "If you see no image in this page, you may need to configure your web server so that it gains access to the symfony_data/web/sf/ directory." ...

Cookie Expiration times

Is is possible to find out when a cookie expires, I have set my cookie up doing this $_COOKIE[] = setcookie("bangUser", $unique, time() + (60*60*24*30)); is possible to print out is expiration date on screen somehow? ...

free lightweight template system

Is there any free, lightweight, template systems made pure with php ( no smarty crap )? Then tell me please :D thanks and DONT recommend me too look into mvc's ...

Adding twitter followers to my DB

i am using a php script to automate posts to twitter. the script to post is woking, but i want it to pull a list of users from my followers automatically. at the moment i am having to import CSV files into my mysql database. i know there is a way that i could pull followers and dump them into the DB directly using twitters API, but I ...

Web API Security

I'm asked to write a Web API for an application (pc executable, not web-app) that will allow sending emails. A user clicks something, the app communicates with the API which generates an email and sends it out. I have to make sure noone unauthorised will have access to the API, so I need to make some kind of authentication and I haven't...

Debugging PHP using Eclipse PDT or Aptana

Guys, has anyone been able to remotely debug a PHP Web page that uses Ajax extensively? (I'm using Zend Debugger, by the way.) When I debug, the parts of the page that are queried through Ajax HTTP GET are not shown. Is any way fix this? ...

PHP Symfony Alias

Hi! Can anyone tell me if there's any way to add an alias to a value of a enum fixture type? Something like this: responsabilityType: values: - ~ - StepAnaliseCC as Credit Responsability notnull: false Thanks in advance, Best regards! ...

How do I avoid reflection injection attacks in PHP?

I'm writing a class that allows you to bridge HTTP requests with class instances using JSON for data, without any implementation in the class you're bridging to. Basically this is how it works: // This is just an ordinary class. $service = new WeatherService(); $jhi = new JsonHttpInterface($service); $jhi->exec(); The JsonHttpInterfa...

Basics rules on UPDATE statement for relational MySql table: for vs while

Hello, I'm doing my first steps with mysql and php, so I have doubts on foundamental rules for a right code optimization. I have a case where my UPDATE statement need to be executed on a certain number of rows, because it should be executed on a relational table, so is a for cicle correct? <? // connection already created $data[] = arr...

Why I am not able to see source code with FF when I have this if statement?

When I add this code, I am not able to see source code with Firefox. Can anyone tell me why please? if (!isset($_SESSION['userid']) || $_SESSION['userid'] < 1){ $this->session->set_flashdata('error',"You must log in!"); redirect('welcome/verify','refresh'); } This code is in the following controller. cl...

retrieve results from mysql using jquery/php/ajax

Hi all, I'm using codeigniter for this project. I have a search form and search form results. Now when I click search in search form I'm being redirected to search form result and I get results. Is it possible to create div or table in search form which is hidden at first then call the search procedure and which results it returns to...

Choosing just the alphanumeric words. Regular Expression. PHP

I'm trying to find the regular expression to find just the alphanumeric words from a string i.e the words that are a combination of alphabets or numbers. If a word is pure numbers or pure characters I need to discard it. ...

Translate sections of text including HTML

Hello What method is the most efficient when translating bunches of text/web pages including HTML? I want to translate the text, but keep the HTML. Also, should I keep the words in a database or an array? ...

Which is most suitable to begin programming (java vs c#) for an intermediate php programmer

Hi guys, i am a php programmer who has no previous programming experience neither in java nor in c#(sharp). My goal is to learn both languages java and c#, so i am looking for an experienced programmer who has in depth knowledge of both languages to suggest me which one to start first in order to make my learning process easier and to he...