I am trying to convert code from mysql to mysqli.
The code uses a single mysql_connect in a file which is included by every other file.
mysql_connect returns a MySQL link identifier that is a superglobal so you can rely on having a database connection available in any of your own functions.
It looks like with mysqli_connect this is not...
Hi,
I am trying to write a script whose efficiency I am trying to measure. I have a couple of questions:-
For small applications, is this kind of profiling required? Or am I getting paranoid? (assuming most code is decently efficient/no infinite loops)
Against what should I benchmark this? What should I compare against?
Below is the e...
Hi
I've been using the following to return filepath and line number of a method
echo (__METHOD__) . "() - ln : " . (__LINE__) . "<br />";
I'd really like to update this to a class (say comment.php)
class comment
{
public static function show()
{
echo (__METHOD__) . "() - ln : " . (__LINE__) . "<br />";
}
}
th...
Hey there,
I'm not too inexperienced with ReWrite (not a master either, though) so I was hoping somone might be able to help me.
RewriteRule ^$ index.php?page=home [NC]
RewriteRule ^adm$ index.php?page=adm_home [NC]
RewriteRule ^adm/stats index.php?page=adm_stats [NC]
Above is a snippet of my .htaccess file. As you can see, when so...
Hello,
I would like to know the best way to save an image from a URL in php.
At the moment I am using
file_put_contents($pk, file_get_contents($PIC_URL));
which is not ideal. I am unable to use curl. Is there a method specifically for this?
...
I want to write a page that will show all the records from a database, and have it limited using the SQL LIMIT syntax.
My question is how would I use PHP to automatically generate the links? Would I have a variable that would automatically increase somehow, hardcode the links in etc, Is there a convention or best practise for this kind...
This article states that
If your site is run on a shared Web
server, be aware that any session
variables can easily be viewed by any
other users on the same server.
On a larger host like GoDaddy, are there really no protections in place against this? Could it really be that easy? If it is that easy, where are the session vars...
We have an old legacy PHP application. Now I want to write a new application module using Ruby on Rails.
Deployment is a one problem. I guess that it should be possible to run PHP app (via mod_php) and RoR app (via mod_proxy / mongrel) on a one Apache server. I don't want to use mod_rails because it requires to run php via fcgi. So is ...
Okay, there is a ton of stuff out there on sanitizing strings but very little, that I can find, on the best methods to prepare user input (like what I'm typing now) for inserting into a content management system then how to filter it coming out.
I'm building two multilingual (Japanese, English + other Romance languages) CMSs and having ...
I have just installed phpMyAdmin on my new Fedora Core 10 dedicated server.
I downloaded the phpMyAdmin-3.1.2-english.tar.gz. I extracted it and placed it in this folder /opt/phpMyAdmin-3.1.2-english and i created a symbolic link in the /var/www/html directory so that I can access it like this: http://www.mydomainname.com/webdb.
When I...
Can't get Wampserver running. Just installed it but get the following in php_error.log:
[28-Jan-2009 10:13:17] PHP Notice: Undefined variable: mywampfp in C:\wamp\scripts\refresh.php on line 252
[28-Jan-2009 10:13:17] PHP Notice: Undefined variable: i in C:\wamp\scripts\refresh.php on line 252
Anyone know what's wrong?
Thanks!
...
Hi,
I have a WCF service with three methods. Two of the methods return custom types (these work as expected), and the third method takes a custom type as a parameter and returns a boolean. When calling the third method via a PHP soap client it returns an 'Object reference not set to an instance of an object' exception.
Example Custom...
I have a basic domain object, say like Person or Campaign or Event that is represented by a single table in the database. However, I also have more complicated versions of these objects say like a PersonCampaign or PersonEvent or even CampaignEvent that could theoretically extend one of the base objects.
However, for a number of reasons...
I need to set up a test environment on my XPSP3 machine that runs Apache, MySQL, and PHP. My original test environment was an old box that ran those three under Win2k. That box died. Running on Windows was never optimal because the ultimate hosting environment is CentOS Linux.
What is the most straightforward way to set up a virtual mac...
I was thinking it be cool to have a simple matchmaker code in php. The idea is the app connect to the server or a specific webpage, the webpage takes it IP and the last X ips and prints it on page (his first)
problem is what happens when 5 ppl hit the page the same second. How do i handle it? i cant use global/shared memory? so i would ...
Hello. I was wondering if I can somehow convert a column header text form MySQL into actial width size pixels. I am trying to generate a PDF from the database and I want it to automatically adjust column widths. As I will use it for many tables, the width must differ so I should be able to see it like: "The header for this column is call...
How does one check to see if a user has typed in the right password to log in?
This is what (out of a bunch of combinations...) I am doing:
<?
$login = $_POST['login'];
$password = $_POST['password'];
mysql_connect('localhost', 'root', 'abc123');
mysql_select_db('aun_vox') or die(mysql_error());
$q = mysql_query("SELECT password FR...
I'd like to work on a bbcode filter for a php website. (I'm using cakephp, it would be a bbcode helper)
I have some requirement.
Bbcodes can be nested. So something like that is valid.
[block]
[block]
[/block]
[block]
[block]
[/block]
[/block]
[/block]
Bbcodes can have 0 or more paramet...
What's the most reliable, generic way to construct a self-referential URL? In other words, I want to generate the http://www.site.com[:port] portion of the URL that the user's browser is hitting. I'm using PHP running under Apache.
A few complications:
Relying on $_SERVER["HTTP_HOST"] is dangerous, because that seems to come straight ...
How can I produce printable reports from a database?
I need to print 1 or two reports per page with about 300 reports.
I'd prefer free methods; I don't want to pay for a big report generator.
...