Quantcast
Channel: PHP Website Development » FALSE
Browsing index pages (34 articles)
↧

counter-intuitive behavior of isset()

I pass a variable $foo to a function. This input variable might be an array or a string. If it is an array, then I want to set:$name = $foo['name']And if it is a string, then I want to set:$name =...

View Article


PHP Exploding String into Multi-level Array

I was wondering if it’s possible to do something like this:Parent1@MiddleA%Child|Child|Child|MiddleB%Child|Child|Child|Parent2@MiddleA%|ChildAnd have it explode into something like...

View Article


PHP: if(function_exists(‘curl_init’)) does that work?

I have some code that that I only want to execute if curl_init() is present. I’m checking for it’s existence with this code:if(function_exists(‘curl_init’)){ $c = curl_init(); curl_setopt($c,...

View Article

CodeIgniter: SQL Audit of all $this-*db-*query() method call

I’m using CodeIgniter 2+ and would like to Audit all $this->db->query($sql); calls.All of our database calls are thru the query() method; no active record usage. I need to record the $sql queries...

View Article

RegExp in preg_match function returning browser error

The following function breaks with the regexp I’ve provided in the $pattern variable. If I change the regexp I’m fine, so I think that’s the problem. I’m not seeing the problem, though, and I’m not...

View Article


Codeigniter – multiple database connections

I have a problem with multiple db connections at Codeigniter. At my database.php i configured two databases. $active_group = ‘cms’;$active_record = FALSE; $db['cms']['hostname'] = ‘localhost’;...

View Article

What is the error in my code that I get mysql_fetch_array wa

I am trying to display some data from mySQL, the db details are correct but I get this. *Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource*What is the error with my...

View Article

Url routing regex help

I’m trying to create a url routing script for my new CMS but must confess that regex isn’t my strong side. So far i keep running into errors or no results.What i’m trying to accomplish is using certain...

View Article


Image may be NSFW.
Clik here to view.

Detecting the “actual” end of an array in PHP

Given I have an array as follows:$array = array(‘a’, ‘b’, 0, ‘c’, null, ‘d’);Now, I can iterate through it easily with foreach of course:foreach($array as $value){ var_dump($value);}And all is fine and...

View Article


curl POST ( CURLOPT_POSTFIELDS )

I am trying to log into a forum and send a message to an user but no effect.

View Article

Split string into 2 pieces by length using PHP

I have a very long string that I want to split into 2 pieces.I ws hoping somebody could help me split the string into 2 separate strings.I need the first string to be 400 characters long and then the...

View Article

Is it true that at times it may be more beneficial NOT to ca

Is it true that at times it may be more beneficial NOT to call mysqli_result::free, mysqli_result::close, mysqli_result::free_result especially when the page itself is short and since php will...

View Article

problem with mysql_num_rows

Here is my code :$sql1 = ‘SELECT * FROM login WHERE age= “$age”, town = “$town” and ID != “$id”‘;$result1 = mysql_query($sql1);$numResults1 = mysql_num_rows($result1);My variables are fine, they have...

View Article


Checking for undefined constants

I’ve seen a lot of people usingdefined(‘XXX’) or define(‘XXX’, ‘XXX’);instead of if(!defined(‘XXX’)){ define(‘XXX’, ‘XXX’);}Does the first code do exactly the same thing? Why do people use...

View Article

error when selecting row from db

I’m trying to select data from a certain row in a my sql db. This is the code im using:mysql_connect($hostname,$username,$password) or die(‘connection error ‘.mysql_error()); mysql_select_db($dbname)...

View Article


Image may be NSFW.
Clik here to view.

php curl vs cli curl, posting xml

UPDATED THANKS TO ANSWERS:Can someone point out the difference between:$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $api_root);curl_setopt($ch, CURLOPT_POST, true);curl_setopt($ch,...

View Article

Image may be NSFW.
Clik here to view.

php curl vs cli curl, posting xml

UPDATED THANKS TO ANSWERS:Can someone point out the difference between:$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $api_root);curl_setopt($ch, CURLOPT_POST, true);curl_setopt($ch,...

View Article


Image may be NSFW.
Clik here to view.

Convert spaces between PRE tags, via DOM parser

Regex was my original idea as a solution, although it soon became apparent a DOM parser would be more appropriate… I’d like to convert spaces to   between PRE tags within a string of HTML text. For...

View Article

What could cause a MySQL error for a single client that cann

Possible Duplicate:mysql_fetch_array() expects parameter 1 to be resource, boolean given in select This issue pretains to SMF ( Simple Machines Forum ). One user cannot login with his details and is...

View Article

Try/Catch not working with this PDO query

I have a script that I am updating by replacing the inline mysql queries with PDO prepared statements and queries. When the query is correct or returns a result, it works fine. However, when there is...

View Article
Browsing index pages (34 articles)


Latest Images