php

How to add 4 hours to time in PHP/MySQL

I'm working on a blog migration from a custom built blog to Wordpress. One of the fields that Wordpress is looking for in the database is a date/time stamp set to GMT, which is 4 hours ahead of our time. So I basically need to take our date/time stamp (in YYYY-MM-DD HH:MM:SS format), and add four hours to it. I was looking at the MySQL c...

PDO mysql: How to know if insert was successful

I'm using PDO to insert a record (mysql and php) $stmt->bindParam(':field1', $field1, PDO::PARAM_STR); $stmt->bindParam(':field2', $field2, PDO::PARAM_STR); $stmt->execute(); Is there a way to know if it inserted successfully, for example if the record was not inserted because it was a duplicate? Edit: of course I can look at the dat...

Can't Insert Data Into Tables Containing Auto Increment Primary Key Using PHP Prepared Statements

I know I have that my connection to the database works, and a test I did using no auto-increment id worked fine for me. The code below refuses to work and I can't find a a way around it. My table has 3 columns, ID (auto increment), name and value. What do I need to change in order to get this to work? Thanks in advance //create placeh...

How to check how many characters in variable, and add space between characters in that var?

I have a 'price' variable that contains some integer number from a MySQL database. I want to check how many numbers the 'price' variable contains, and add a space in the variable depending on how many numbers. See below: Example: If 'price' is 150000 I would like the output to be 150 000 (notice the space). OR, if it is 19000 I would ...

why doesn't this number_format work?

Hi. while($row = mysql_fetch_array($qry_result)){ $price_to_show=$row['price']; number_format($price_to_show, 0, ',', ' '); echo $price_to_show; Why doesnt the above give the space separator? It outputs the same as before the number format, what is wrong here? Thanks ...

Magento error: SQLSTATE[HY000]: General error: 1

Hi all, I hope this question is ok for Stack Overflow – If it’s not appropriate then let me know and I’ll remove if that’s the case. Magento has been recently giving me the following error when I visit the shop on a windows machine: SQLSTATE[HY000]: General error: 1 Can’t create/write to file ‘C:\WINDOWS\TEMP#sql_ac0_0.MYI’ (E...

Wordpress Split Archives into 5 sections based on Category and tags

On my site (currently PHP5, wordpress 2.8.5) I have a lot of categories total=150. Each category is a City name ie: Paris, this has a tag associated with this category. ie: Hotel, Sports, Bars, Entertainment, Food total->5 On my Archive page I'm looking to produce a tabbed section based on my tags. ie: tab 1: tag->Hotel-> lists all ...

Possible to use PHP GD's imagecreatefromgif() and imagettftext() together?

Basically I am looking for a way to write dynamic text on top of a GIF [preferably via PHP GD.] But I can't seem to get these two functions to play nice. For reference: imagecreatefromgif & imagettftext function load_gif($imgname) { $im = @imagecreatefromgif($imgname); if(!$im) { $im = imagecreatetruecolor(150,30)...

Sending a delte.php properly to my db

Hello all, I have a function on my that has a delete button to erase comments. I have the button all linked up and ready to go. I just don't know what I should put on the 'delte.php' script I am creating, and what to tell it php wise to send to the db to make the status dead. as well as deleting the comment off of the page. Thanks ...

Compressing a string, end result without line breaks?

I'm trying to compress any given string to a shorter version, copy paste-able compressed string that doesn't contain any line breaks. I tried gzcompress, but then copy/pasting the result into a different php script and trying to gzuncompress throws "Warning: gzuncompress(): data error" Is there any native php function that compresses a...

Delete help for my script

So I almost have my delete function working...I have the page loading correctly without any fatal errors but still not doing the trick Here is the portion of my while loop: echo "<a href='http://www.@#@$#%##%#.org/Profile.php?id=".$prof-&gt;id."'&gt;"; echo " delete"; echo "</a>"; and here is the portion of my query which is obviousl...

[PHP]: Is it possible to access .NET DLL through PHP?

I have a .NET DLL containing functions that I can use in PHP. Though various PHP libraries are available, but I just wanted to know whether PHP supports libraries written in other languages? In future if I write a library in Ruby and want to use it with PHP, is it possible? ...

RSA Encryption: Java to PHP

I'm trying to implement RSA Encryption in both Java and PHP, but I can't seem to get PHP to recognize my Java public/private keys. Here is the java code to Encode/Decode the Public and Private Keys: public static byte[] EncodePublicKey(PublicKey _publickey) throws Exception { return _publickey.getEncoded(); } public static PublicKe...

WCF Interop with PHP behind a load balancer

I'm trying to help a customer interop w/ a PHP client but we have a load balancer that is in front of the IIS farm. Because of this when you actually view the .svc?wsdl you get specific server listed inside this WSDL. Then when my customer is trying to generate a client using something like so $client = new SupplierService(); They g...

PHP and db connections

When I load a php page on my browser, it connects to the DB and runs some sql... let's say I now follow a link and it takes me to another page within the same website. What happened server wise? Did my first connection to the DB close, and re-opened again? Is that what happens in most cases? ...

Is this file uploading method secure via PHP?

I use the PHP language for file upload and want to know that the following method that I use is secure or not? I am using simple method for file uploading, I check the file name from $_FILES['userfile']['type'] and then if it's having an allowed file extension, I upload the file with some random number. Like if it is abc.zip it may beco...

Using Zend framework components in not ZF based projects

I'm working on a project now that isn't based on Zend Framework, however I would like to use some of Zend's components in it, namely Zend_Form and Zend_Acl. The question is, what should I do in order to make these components know how to load their classes correctly when they are instantiated. I suppose spl_register_autoload and set_inc...

PHP != and == operators

This has boggled me for a while. I am running through a directory and echo'ing out its contents and I want to exclude the ".." and "." files. Now, this code works: if($files = scandir("temp/")) { foreach ($files as $file) { if($file == ".." OR $file == ".") {} else { echo $file; echo "<br>"; } } }...

Ifstatement used to make a functionality button appear?

I am on my 2nd day(16th hour) of trying to get my delete button to do what I want with PHP. I have a site that is a social network that has user profiles. Users can leave comments on another users profile. I am trying to put a delete link in a designated area that only shows up if you are viewing your own profile and goes away when you a...

PHP Class Variable problem

I have this class: class TestClass { var $testvar; public function __construct() { $this->$testvar = "Hullo"; echo($this->$testvar); } } And this method for accessing: function getCurrent() { $gen = new TestClass(); } I get the following error: Notice: Undefined variable: testvar in /Users/myuser/S...