php

Why use mysql_real_escape_string, doesn't addslashes prevent everything?

I was looking through the docs and stumbled onto mysql_real_escape_string() and I'm not understanding why it's useful when you can just addslashes(). Can someone show me a scenario as to why it's useful? I'm also curious why it requires a database connection.... that seems like a lot of overhead. ...

MySQL JOIN, via PHP, when there is no data in one of the tables?

How do you deal with a join statement if one of the tables you are joining does not have any data for the user in it. For example: -user_1 is listed in all tables. -user_2 is listed in table_1, table_2, and table_3 but not in table_4. The following query fails because user_2 is not in table_4. $query = "SELECT table_1.username, tabl...

Why is my "Page [0]" not centered in my webpage?

My "Page [0]" text isn't centered on my webpage. Anyone know why? I could really use some help please. Here is the html: <html> <head> <title>Test Forum</title> <link href="http://prime.programming-designs.com/test_forum/style.css" rel="stylesheet" type="text/css" /> </head> <body> <a href="http...

Question about wordpress plugin

http://demo.thethemefoundry.com/traction/#post-183 Which wordpress plugin is this, to have post image on the left side and shortened version of your post on the right, and read more button below? Thank you ...

PHP Menu Question

As one of the steps toward a greater website redesign I am putting the majority of the content of our website into html files to be used as includes. I am intending on passing a variable to the PHP template page through the URL to call the proper include. Our website has many programs that each need an index page as well as about 5 sub...

Preventing SQL injecting in a database class

I'm building a database class and thought it'd be a good idea to incorporate some form of SQL injection prevention (duh!). Here's the method that runs a database query: class DB { var $db_host = 'localhost'; var $db_user = 'root'; var $db_passwd = ''; var $db_name = 'whatever'; function query($sql) { ...

How does PHP know what the last database connection is when mysql_select_db() or mysql_query() is used without the optional database parameter?

Consider the following code: <?php $conn = mysql_connect('localhost', 'username', 'password'); mysql_select_db('database', $conn); ?> This works as expected, but how does PHP know what database connection to use when calling mysql_select_db() in the following example? <?php mysql_connect('localhost', 'username', 'password'); mysql...

On form submittal, a tick kills the app. But only in production.

A client just recently moved an application through the stages to production. I set up a testing environment on an "out-of-the-box" LAMP server, and can submit a form with a tick in the textarea. But in production the exact same code dies, but doesn't even execute the "or die();" I mysql_real_escape_string the input, which is why it w...

Android JSON HttpClient to send data to PHP server with HttpResponse

I am currently trying to send some data from and Android application to a php server (both are controlled by me). There is alot of data collected on a form in the app, this is written to the database. This all works. In my main code, firstly I create a JSONObject (I have cut it down here for this example): JSONObject j = new JSONObje...

Unable to access MySQL from MyPHPAdmin after setting root password in EasyPHP{WAMP}

Am a new starter with WAMP and trying to play around my way using the EasyPHP setup. After successful setup on intial launch of MySQL, the page prompted me to set up ROOT password for security reasons. On setting the password, am no longer able to access MySQL. The error is : Error MySQL said: Documentation 1045 - Access denied for us...

Double-byte characters in querystring using PHP

I'm trying to figure out how to create personalized urls for double-byte languages. For example, this url from Amazon Japan has Japanese characters within the querystring (specifically, the path): http://www.amazon.co.jp/風の谷のナウシカ-DVD-宮崎駿/dp/B00005R5J3/ref=sr_1_3?ie=UTF8&amp;s=dvd&amp;qid=1269891925&amp;sr=8-3 What I would like to do ...

How do I make textarea a TinyMCE in Joomla?

I have a component and I want to make a textarea on the admin backend interface use the TinyMCE editor: How do I reference the TinyMCE that is being used by other components (instead of duplicating it) 2.) How do I hook into the page init or some place where I can let TinyMCE do it's magic (of if Joomla provides a way) Thanks ...

Why aren't my MySQL Group By Hours vs Half Hours files Not displaying same data?

I need to be able to display data that I have in 15 minute increments in different display types. I have two queries that are giving me trouble. One shows data by half an hour, the other shows data by hour. The only issue is that the data totals change between queries. It's not counting the data that happens between the time frames,...

How do I make these inputs relate to each other?

I have a series of checkbox inputs and corresponding text area inputs to allow specification of quantity. Here's what the two fields look like when the item is static (i.e. only 1): <input type="checkbox" name="measure[checked][]" value="<?=$item->id?>"> <input type="hidden" name="measure[quantity][]" value="1" /> Here's what the inp...

Sort/Group XML data with PHP?

I'm trying to make a page using data from the discogs.com (XML)-API. i've been parsing it with simpleXML and it's working pretty well but there is some things i'm not sure how to do. Here is part of the XML: <releases> <release id="1468764" status="Accepted" type="Main"> <title>Versions</title> <format>12", EP</format> <l...

Architecture for multiple web apps and databases.

We used to have only one web app, but now we are breaking it down into multiple ones. Each one will be packaged as separate product (web app) Some have things in common some do not. It was originally coded with php and using Postgresql 8.4 and CodeIgniter as the framework. I am looking for some good suggestions on how I should set up ...

How do I see the results of unique records added after adding records to mysql

I'm a PHP noob. I have a database that I will update weekly with a CSV. So far I've managed to upload the file to the server, open the file with PHP, and insert the data in my table. Now I want to return the unique records that were added (on screen or in a file). How do I do this? ...

What is the proper PHP syntax to post a file that exists in a directory that's on the server?

This is a basic post form in PHP that loads from the client PC. What is the proper syntax to load from a directory on the server? <form enctype="multipart/form-data" action="index.php?option=com_productionparse" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="90000000000" /><br /> Choose a file to upload: <input name="f...

PHP mailer containing HTML not showing correctly

Hi guys, here is some code I've been working on, basically I need to set up a auto e-mail that gets sent to a user after they fill in a form, which at the moment it is doing, but the HTML is not displaying as it should inside of the email client. I checked in Gmail, Outlook and Mac mail and none of them display the HTML correctly. Here...

How do I create a loop based off this array?

I'm trying to process this array, first testing for the presence of a check, then extrapolating the data from quantity to return a valid price. Here's the input for fixed amounts of items, with no variable quantity. <input type="checkbox" name="measure[<?=$item->id?>][checked]" value="<?=$item->id?>"> <input type="hidden" name="measure...