php

Validating forms in HTML, PHP, and JavaScript

If I am defining a function in JavaScript at the top of my page that validates if the string entered in a form is (A-Z,a-z, or 0-9). And then I call that function when they submit it saying : onsubmit="return Validator(this);" If the function name is : function Validator(form) Why isn't it actually validating the string submitted w...

PHP IDE with design view?

Are there any good IDEs for PHP that have design view as well? Like in Dreamweaver, or visual studio, sometimes it is advantageous to place controls with drag and drop. Also want syntax highlighting and some kind of versioning control. I know this question is quite like others asking about PHP but I specifically desire this feature....

long polling - what are methods for determining when you have new data?

Lets say I have a chat program that every time someone sends a message, a globalfile is locked and written to. The receiving client has a pending xmlhttp request that is waiting to return with the newly updated file using this construct: while (!hasNewdata()) { sleep 3; } print "$thenewdata"; sub hasNewData() { # determine if...

auto increment with a string of numbers and letters

Right now im using auto increment to identify resources in my website. The problem is i dont want the users to know how many resources there are. How could i instead use some kind of structured "random" combination of letters and numbers (say 6 digits) that i could use instead of (or in addition to) the auto incrementing primary key nu...

What is the syntax for counting number of rows in PHP Prepared Statement?

Hi, In using PHP Prepared Statement, what is the syntax for counting number of rows? $stmt = $conn->stmt_init(); $query = "SELECT * FROM TableName"; if($stmt->prepare($query)){ $stmt->num_row(); //SOMETHING SIMILAR TO THIS.... } ...

how i had to specify .htpasswd file path in .htaccess relative or absolute.

I created a password protected folder using .htpasswd. In .htacces how should i specify this .htpasswd file. like this AuthUserFile http://alertalert.freetzi.com/admin/.htpasswd or like this AuthUserFile /admin/.htpasswd or any other method. Plz help ...

One ID for every database column, how to do?

I working on a food database, every food has a list of properties (fats, energy, vitamins, etc.) These props are composed by 50 different columns of proteins, fat, carbohydrates, vitamins, elements, etc.. (they are a lot) the number of columns could increase in the future, but not too much, 80 for extreme case Each column needs an indiv...

username and password not accpeted when using .htaccess and .htpasswd?

I used .htaccess and .htpasswd to restrict the admin folder which is located at root/admin for that i used the following .htaccess file AuthName "Alertalert" AuthType Basic AuthUserFile http://alertalert.freetzi.com/admin/.htpasswd require valid-user .htpasswd file rajasekar:$apr1$0yd92n1r$McIxIiQXPRF1u3gRBNRNc1 the .htaccess an...

How to concatenate parameter in query

I want to use a parameter in the following query, but I am not really sure how to. If you can help me, I will be greatful. $id will be 1, 2 or 3 etc. and I want to select where C.Name is Galleri1, or Galleri2 etc. This is what I got so far, but I am not sure how to add $id. function getGallery($id){ $data = array(); $Q = $this->db...

How to find a word NOT preceded by another specific word?

Which regular expression can I use to find all strings bar are not preceded by string foo? Having whitespace between the two is also illegal. So the regex should match the following strings foo is bar hello bar But not these foobar foo bar I've tried using the following (?!<foo)bar and it gets the work done for eliminating ...

regex - match not in tag

this should be easy but somehow I can't figure it out: I have HTML snippet like this one: <p style="padding:0 10 20 30; margin: 1 2 3 4 ">This is 201 some 20 text 1 <b>30</b> with some numbers 30 20</p> ... I need to match numbers 1, 20, 30 (only those) and replace them with links. Obviously I do not want to replace numbers inside tag ...

Extract 2 sets of numbers from a string using PHP's preg?

Here's some PHP code: $myText = 'ABC #12345 (2009) XYZ'; $myNum1 = null; $myNum2 = null; How do I add the first set of numbers from $myText after the # in to $myNum1 and the second numbers from $myText that are in between the () in to $myNum2. How would I do that? ...

Javascript links made by php in Firefox.

I'm working on a script and it works fine in IE and Chrome, but the links do not work in Firefox. Basically I am using php to query a database and generate some links inside the page. Example of the relevant link code: <TD class="bodycopyblue" onmouseover="this.style.background='#FFFF80';this.style.cursor='pointer'" onmouseout...

How to update two tables with MySQL and PHP?

I was wondering how do I update two tables using mysql and php? How would I add the second table to the code? Here is the code below. $dbc = mysqli_query($mysqli,"UPDATE tags SET count='$tag_info_count' WHERE id='$tag_info_id'") ...

Get array with results of object method on each item in an array of objects in PHP

I have an array of objects and I want to convert it to an array of the result of a method of each of them. I can do this just fine, but I'm wondering if there is a cleaner / better approach to it maybe? For example, pretend this is what I'm working with and how I'm doing it now: $objects = array(); $objects[] = new Dog(); $objects[] ...

protect from and simulate a data center outage

Recently the data center I'm using experienced an outage. During the outage customers using my service reported that their websites were very slow. The customers integrate my service in two places: 1. A script tag in web pages that pointing to my server. 2. making API calls against my server with php: fputs($fp, "POST $path HTTP/1.1\r\n"...

Display error when entire form is blank in CodeIgniter

I'm trying to create a fairly simple form that has a few checkboxes and input fields and a textarea. Nothing is required by itself; however, if 'A' checkbox is checked, then 'A' input field is required (and so on for the couple other checkboxes I have). I have the above functionality in place, but I'm having a tough time figuring out h...

SQL: Refactoring a GROUP_CONCAT query

My eventual goal is to generate tag links for blog posts, the tags relating to the post. Currently my query has a GROUP_CONCAT which grabs relating tags and the returning tags column value is something like: 'Brooklyn, Manhattan, New York' from SELECT post.id, post.name, GROUP_CONCAT( tags.name order by tags.name ) AS tags...

Using PHP to Convert ASCII Character to Decimal Equivalent

Can someone suggest a (preferably) graceful way to convert an ASCII character to its decimal equivalent using PHP? ...

MySQL: Pulling the current user's vote on a query of links.

So I have this query that pulls from my links and votes table and I need one last column of data. My votes table consists of every user's vote, a user can only vote once per link and their vote value is either -1, 0 or 1. There is a user_id foreign key in the votes table and I want to somehow gather the current user's vote. I feel the...