php

$_REQUEST value appearing in \'value\'

i am trying this to pass a value to the next PHP page: $("#see_comments").attr({href: "comments.php?aid='"+imgnum+"'"}); and in the PHP file I am using: $aid = $_REQUEST[aid]; echo $aid; but this is displaying the output like this: \'9\' why is this happening? //9 is the value i am passing. ...

PHP Framework OOP model

Hello, I think I am experienced procedural PHP programmer. I've implemented a few bigger projects. Now I would like to try OOP PHP on lesser one (framework for DB import/export + user authentication). Since I've never tried OOP on such a project I have problem with object design. I would like to implement the framework the way, I'll ju...

MySQL 4.0.18 syntax error while using GROUP BY

I have a project management website running on PHP and MySQL. But I am not the person who developed it, which makes it harder for me to figure out what the problem is. So I turned to stack overflow. When I try to sort a list of objects, MySQL server throws an exception at me, saying: "You have an error in your SQL syntax. Check the ...

extract domain or domain with subdomain from a link ?

hi, i need a php function to extract domain with tld from a url or domain with tld and subdomain if there is. example: http://minova.tumblr.com/post/145515 >> minova.tumblr.com http://www.tumblr.com/about/1 >> tumblr.com Thanks ...

Output text file with line breaks in PHP

I'm trying to open a text file and output its contents with the code below. The text file includes line breaks but when I echo the file its unformatted. How do I fix this? Thanks. <html> <head> </head> <body> $fh = fopen("filename.txt", 'r'); $pageText = fread($fh, 25000); echo $pageText; </body> </html...

PHP -What's the difference between global variables and constants

According to many sources, register_globals (global variables that is) should be disables in your php.ini. Should I write define() in my code and use constants if global variables are disabled? Are those even related? ...

PHP: Parse different styles of friendly urls

Hello. I am writting my own small framework and I am going to implement friendly URLs there. mod_rewrite is great. But I want to be able to handle several types of friendly URLS at once: /index.php?ac=user&an=showprofile (fallback variant, the worst) /index.php/user/showprofile (supposedly, can be disabled by security settings) index.p...

PHP: Get list of all filenames contained within my images directory

Hi, I have been trying to figure out a way to list all files contained within a directory. I'm not quite good enough with php to solve it on my own so hopefully someone here can help me out. I need a simple php script that will load all filenames contained within my images directory into an array. Any help would be greatly appreciate...

PHP Design Pattern

Hi, I have a class that performs database operations and returns results (array, true, false). And I have an another class that creates JSON string by using this class in its constructor. Can we say this class is an Adapter? Or simply wrapper or ... Class Db { public function getRows($params) { //... } } Class DbAd...

How to determine if a url is an image or not?

hello. i want to know from the syntax if a url is a picture or not. example: http://www.blah.com/plo52.jpg or png or gif will return true. if the url is ending with other extension, the function will return false. Thanks ...

php string error

i am experiencing some weird behaviour here. i am using the following code to reference the facebook api. $query = "SELECT msg, user_id, comment_time FROM comments WHERE aid = '$aid' ORDER BY comment_time DESC"; $result = mysql_query($query) or die("ERROR: $query.".mysql_error()); if (mysql_num_rows($result) > 0) { ...

php script crashing apache

This script crashes apache. I removed url on purpose. Can anyone take a look and offer alternatives? Thanks! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml"&gt; <head> <meta http-equiv="Content-Type" content="text/h...

PHP: run linux command as sudo?

I'm in a bit of trouble and need to run a linux command as sudo using php. Is this possible using php's exec()? I've tried but cannot enter the sudo password and then execute another command on the same exec() call. edit: i cannot access the server remotely via ssh due to own stupidity. That's why i have to run commands thru the web ser...

PDO exec doesn't return value on deletion of record

When I delete a record from the database, even when it is successful, all I ever get is int(0). What am I doing wrong? The manual does not give an example of this with a procedure. $foo = db::getInstance()->exec("CALL deleteUser(222)"); ...

Jquery - Send variables to a controller Action via GET in AJAX

All, I want to send a variable "itemId" via GET to a controller action through AJAX. In the Controller Action, I should be able to retrieve the value using $_GET["itemId"]; Can I send the querystring with "data" tag instead of appending it to the "url"? I have the following code: $.ajax({ type: 'GET', url: "/con...

how do I install this php word censor for phpBB?

Hi I am trying to add a list of words to be censored. So I found this site http://www.phpbbsmith.com/projects/phpbb3/word-censor-list.html that does it for phpBB. I downloaded the file and I put it in my root folder. I get this error Fatal error: Call to a member function session_begin() on a non-object in C:\HostingSpaces\SomeName...

Does the GD library use a lot of memory?

I want to use GD library in my PHP script to generate a small thumbnail of a random big picture from external server. Every time the page is called, the GD library will regenerate a thumbnail and show it. Will this slow down the server or use up an unusual amount of memory? ...

need to test if sql query was successful

I have this query and if it returns successful, I want another function to process, if not, do not process that function. Here is the code for running the query global $DB; $DB->query("UPDATE exp_members SET group_id = '$group_id' WHERE member_id = '$member_id'"); I imagine it is something like... if($DB) { //success } else { ...

PHP what is the best approach to using XML? Need to create and parse XML responses

What are the recommended libraries for XML in PHP? Advantages? Looking to create/send/parse XML. Needs to support High Volume (Millions of calls per day) ...

pagination in php

i am using this to collect comments made abt a particular user. i want to display 7 comments on each page and want to enable pagination. what would be the steps of implementation. sorry. n00b question. $query = "SELECT msg, user_id, comment_time FROM comments WHERE aid = '$aid' ORDER BY comment_time DESC"; $result = mysql_query...