php

Check if at least 75% of a string is UPPERCASE

Hi, I'm writing bug tracking software in PHP, and today I saw this in another bug tracker: http://bugs.php.net/bug.php?id=12017 Now I want to add a feature in my software which will block titles where at least 75% of all characters is uppercase. How can I do this? Thanks, P.S. CSS will not work, because, for example if you have the w...

Returning SQL Insert ID when using Jquery/AJAX to insert row into database

Im trying to add an element to a database and then return a new id for it based on the the sql_insert_id Its adding the element correctly and the console is returning the id i want to use but for some reason its not actually changing it on the element. Im just using an echo in my actions.php script to return the string. $(".add").clic...

Calling a method once all the script processing has completed

I'm trying to do a bit of "fancy"/"experimental" php so that you can include a header script (called crt0 :-p) that defines a basic application class that you can inherit. It then provides a function that checks your classes and finds one that is subclassing it's application class and calls the "Main" function. This way you include the ...

OO PHP where to reference singleton class?

Hi, I am going to use singleton classes to manage both DB connections and references to application settings. It seems a little messy to have to use the following code in every method in order to access the db class. $db = DB::getInstance(); Is there a more efficient way of going about it? Any advice appreciated. Thanks ...

Writing to a COM port with .Net

How would I go about writing to a COM port, trying to convert the following example to .Net (C#), specifically the PHP part? If possible is there an easier way to write out to a USB? ...

phpThumb cache problems

I'm using phpThumb - the PHP thumbnail generator. 'phpThumb.config.php': $PHPTHUMB_CONFIG['cache_maxage'] = 10; $PHPTHUMB_CONFIG['cache_maxsize'] = 1000; $PHPTHUMB_CONFIG['cache_maxfiles'] = 10; but it does nothing... I've got 108 MB in 922 files... and it keeps growing. Thanks for any suggestions. ...

Php : running ssh from Windows to login to a Linux and run a script

Hi ! Here's my goal : I have a Windows XP PC with all the source code in it and a development database. Let's call it "pc.dev.XP". I have a destination computer that runs Linux. Let's call it "pc.demo.Linux". Here's what I've done on "pc.dev.XP" (just so you get the context) : installed all cygwin stuff created a valid rsa key and p...

How can I use PHP to find a row in a MySQL DB table and insert just one value?

For example, I know I can make a new row and enter values into all fields doing this: mysql_query('INSERT INTO table_name VALUES ( "id77" ,"some value" )'); Assuming the name of the first field ("id77") is "myID" and the name of the second field ("some value") is "foo"... How can I use PHP find the row with myID = id77 and change th...

A php function to insert or update mysql table on true/false

Im trying to write a function to check whether a user exists in a table, if so, update the row, if not, insert it. Here is my function: function UserExists($screenname){ $mysql = mysql_fetch_array ( mysql_query("SELECT * FROM `users` WHERE `screenname` = '$screenname' ")); if($mysql){ return TRUE; }else...

Why, when I'm adding two integers, does PHP return a bad result (6+7=1)?

I have two variables: $qty = 7; $_POST['qty'] = 6; var_dump($qty, $_POST['qty']); // both vars are integers $_SESSION['qty'] = $qty + $_POST['qty']; echo '='.$_SESSION['qty']; This returns: int(7) int(6) =1 (int)$qty, (int)$_POST['qty'] doesn't solve the problem. What am I doing wrong? Update: ... intval($qty) + intval($_POST['...

Module 'eAccelerator' already loaded php warning

I'm getting this PHP warning in my error_log and want to get it fixed. I'm told it is loaded within php.ini which I've verified as well as a bunch of configuration settings for the module. I'd like to maintain the module configuration in the place where it's loaded so I need to find out how else to remove it from the list. Unless remo...

path problem with mod_rewrite, XDebug, PDT, XAMPP and Windows XP

My mod_rewrite turns accounts/create into index.php?folder=accounts&action=create, but pdt ignores it, so when I try to start a PHP Script debug session, I have to type a folder location in the file field and pdt doesn't accept. When PDT auto generates the URL for the PHP Web Page debug session, I go to http://localhost/myframe/index.ph...

[HTML/PHP]: Abort refresh of page.

In a Form, I am calling a PHP file if the validation passes. My Form header looks like this: <form method="POST" action="inst.php" style="margin:0px;"name="form1" onSubmit="return CheckUsername(document.getElementById('username').value);"> </form> The problem is that even if the validation fails, it shows a blank page in an attempt t...

getenv("HTTP_XXX) return nothing

Hello! Why this code return "" : $ip = ""; if(getenv("HTTP_CLIENT_IP")) { $ip = getenv("HTTP_CLIENT_IP"); } elseif(getenv("HTTP_X_FORWARDED_FOR")) { $ip = getenv("HTTP_X_FORWARDED_FOR"); } else { $ip = getenv("REMOTE_ADDR"); } Environment: W2003EE, IIS 6.0, PHP 5.2.9 (ISAPI) $_SERVER is a built-in PHP variable. getenv() look...

Storing PDO details in php.ini

According to the PDO documentation, you can store database login details in php.ini, away from the php file (example 3). But it does not explain how to store username and password, only the database and host. How would you do that? This is the method used in the documentation: [PDO] pdo.dsn.mydb="mysql:dbname=testdb;host=localhost" I...

PHP short unique ID generation using auto_increment?

I would like to generate a short, unique ID without having to check for collisions. I currently do something like this, but the ID I currently generate is random and checking for collisions in a loop is annoying and will get expensive if the number of records grows significantly. Normally worrying about collisions isn't an issue, but t...

problem with saving data like 12 ÷ 5

i have following data to save in database using php my data is : 12 ÷ 5 i have following code $.ajax({ type: "POST", url: "add_proc.php", data: "topic="+ encodeURIComponent(field1) when i check value of field1 in firebug its same (12 ÷ 5) but when value save in database is 12 ÷ 5 $topic=mysql_escape_str...

Adding unobtrusive progress bar to old-school file uploads

You all know the new generation of fancy, mostly Flash-based file uploaders like SWFUpload that can show a progress bar while uploading - a great improvement especially for shaky and low-bandwidth connections. However, these uploaders all bring their own logic of how to handle uploads on the client side. I am looking for an unobtrusive ...

Using the Salesforce PHP API to generate a User Profile Report

Hi All, Looking to do a security audit of all user permissions. I think I can use the Salesforce PHPToolkit 11 API to generate the report but new to Salesforce and a little confused on where to start. In Salesforce Setup Under: Administration Setup -> Manage Users -> Profiles -> Profile Names If you click on each user name you can ...

How would I skew an image with GD Library?

I want to skew an image into a trapezoidal shape. The left and right edges need to be straight up and down; the top and left edges need to be angular. I have no idea what the best way to do this is. I'm using GD Library and PHP. Can anyone point me in the right direction? Thanks, Jason ...