php

MySQL PHP count(*) returning something weird

I'm running the following query, expecting it to return an INTEGER, but it returns "Resource id #3" What am I doing wrong? $queryPlans = mysql_query("SELECT count(*) FROM infostash.rooms"); echo $queryPlans; There are actually 15 rows in this table, and I would like to return the number 15. Any suggestions? ...

php script 403 forbidden error

Hello, I have a script giving me error 403 Forbidden error, its just a copy of another script but the different in this is that both use another mysql class to access database. My whole project is complete and this is last file so i dont want to do the whole work again for a single file. Server logs shows that client denied by server ...

Server/Client Verification?

We're considering creating a program which sends a POST request to a server-side program for some processing. We'd like to consider some sort of verification to make sure the POST request isn't a random spammer attempting to overwhelm our system or something. I don't know too much about this stuff, but I was thinking the client might s...

php data structure - xml or tree?

i want to write a generalized function that can output something like this. <span class="side_title">By Collection</span> <ul class="menu"> <li class="top"> <a class="top_menu" href="#url">home</a> </li> <li class="sub"> <a h...

Delphi to PHP, Java or Ruby?

We're starting to think about the next stage of our company information strategy. At the moment various departments have Delphi VCL applications that focus on the information that they manage about their Projects. Behind the scenes we've been making sure that the thinking joins up. We're now at the point where we want to give people t...

Filters in Doctrine

nHibernate has a great feature called filters, so i can create criterias globally for my applications. I'm starting a project in PHP and i need to use an ORM, i'd like to know if Doctrine has a similar feature to manage query conditions. thanks ...

Good PHP Metric tools

I have been coding in PHP for a while using Netbeans but it does not provide any tools for obtaining code metrics. I have also used SourceMonitor before but it does not support PHP, same with Code Analyzer. Has anyone used and can recommend any tools for getting code metrics from PHP code? ...

error executing shell script in PHP

I am trying to execute a shell command via: <php echo shell_execute("tac /home/kusmuk/access-logs/kusmuk.org"); ?> But it does not give any output. What could be the reason? Although it does not work, the following lines work as expected: <php echo shell_execute("ls -al triogrup.com"); ?> //outputs: -rw-r----- 2 root kusmuk 28640 Au...

Mod_Rewrite Question

Hello, I'm trying to forward example.com/signup and example.com/signup/ (with trailing slash) to example.com/signup.php I wrote following to .htaccess and it works for example.com/signup/ but doesn't work without trailing slash... How can I solve the problem? RewriteEngine On RewriteRule ^question/(.*)-(.*) /question.php?qid=$1 Rewrit...

What ways are there to validate PHP code?

What ways are there to validate PHP code? I have tried the PHPEclipse plugin which works well but I would like to use a web-based one which is easier to access and use if there is any or maybe a smaller application. Ideas, tips, hints anyone? ...

php infinite loop

Hello, This function gives me an infinite loop function getCats($parent,$level){ // retrieve all children of $parent $result = ""; $query = "SELECT title,parent_id from t_cats where parent_id = '$parent'"; if($rs = C_DB::fetchRecordset($query)){ while($row = C_DB::fetchRow($rs)){ $result .= str_repeat($paren...

Javascript redirect vs PHP redirect, which would search engines see as regular content

I'm guessing that using PHP's header("location: here.html") would be much better javascript's window.location("here.html") as far as search engine visibility goes. I would assume that the server redirect would show google the correct content and the javascript redirect would be read as a page with the javascript redirect code in it. Rea...

Python - substr

Hi I need to be able to get the last digit of a number. i.e., I need 2 to be returned from: 12. Like this in PHP: $minute = substr(date('i'), -1) but I need this in Python. Any ideas ...

What is the best way to reuse code in PHP?

Code: if ( $_GET['tab'] == 'newest' ) { // Go through each question foreach( array_reverse( $end_array, true ) as $tags_and_Qid['question_id'] => $titles_and_Qid['title'] ) { // Grab the title for the first array $title = $titles [ $tags_and_Qid['question_id'] ] ['title']; // Grab the tags ...

array foreach problem

Hello, I am having some problem with foreach statement.Though the input to foreach statement is an array, it says Invalid argument supplied for foreach() and my code looks like this foreach($res_array as $res) { foreach($res as $re) { echo $re['shortUrl']; } } and my array looks like this...

Return Random Number but not 2

Why is it this sometimes returns 2? function pickServer(){ $varr = rand(1,4); if($varr==2){ pickServer(); } return $varr; } ...

Quick question about sessions in PHP

Sessions are started via session_start(), I realize that much, but to make sessions persistent, they need an ID. Now, the php.ini file has a setting: session.use_cookies = 1 So I don't have to pass the ID around. But there's another setting: ; Lifetime in seconds of cookie or, if 0, until browser is restarted. session.cookie_lifetim...

imagegrabwindow opens two windows and grabs the wrong screenshot

Hi, I am wanting to grab a screenshot using PHP and on my local Vista machine. For starters I just wanted to get the standard example set up: $browser = new COM("InternetExplorer.Application"); $handle = $browser->HWND; $browser->Visible = true; $browser->Navigate("http://www.libgd.org"); /* Still working? */ while ($browser->Busy) { ...

How to detect mod_rewrite without apache_get_modules()?

Is it possible to detect mod_rewrite in PHP when function apache_get_modules() is not available? ...

Drupal 6 Views 2: Setting Date Arguments

Passing uid as an argument works fine with this code: $bouts = views_get_view_result('Results', 'page_1', array($user->uid)); The key line in views_get_view_result that sets arguments is: $view->set_arguments($args); But what about passing date ranges? Also, if something is specified as a filter on a view, is there a way to proram...