Monthly Archives: January 2011

Biting off more than I can chew… first PHP project

For my first PHP project, while I learn this PHP/MySQL thing, I’m creating a sort of Social Media website…. users register and join, upload photos, make friends, send messages, etc… This project will use a lot of web technologies to … Continue reading

Posted in Uncategorized | Comments Off on Biting off more than I can chew… first PHP project

ASP Response.Redirect vs. PHP Header location

My old ASP habits are sometimes hard to break… I like the simpler redirect equivalent of ASP compared to the PHP header location command: // redirect to thank you page header( ‘Location: /thankyou.php’ ) ; So… I just made a … Continue reading

Posted in Uncategorized | Comments Off on ASP Response.Redirect vs. PHP Header location

PHP Session Handling vs. ASP Session Handling

Just because you created a session variable in PHP, using this statement: session_start(); // store session variables to designate that the user is successfully logged in! $_SESSION[“login”] = TRUE; $_SESSION[“username”] = $varUserName;    doesn’t mean you can automatically access the $_SESSION(“login”) … Continue reading

Posted in Uncategorized | Comments Off on PHP Session Handling vs. ASP Session Handling

ASP Response.Redirect vs. PHP Header location

Be careful that you don’t have any extra blank spaces in the PHP file… if you try to do a “redirect”, you’ll get an error. <?php //****************** INCLUDE ******************* include(‘include/common.php’); include(‘include/dbconnect.php’); ?> <?php // check if form submitted if ($_SERVER[‘REQUEST_METHOD’] … Continue reading

Posted in Uncategorized | Comments Off on ASP Response.Redirect vs. PHP Header location

PHP Error Reporting

It’s possible to enable or disable display of error messages in your PHP program by using the command error_reporting(‘some constant’);     // see below for values of constant Errors and Logging Value Constant Description Note 1 E_ERROR (integer) Fatal run-time errors. … Continue reading

Posted in Uncategorized | Comments Off on PHP Error Reporting

SQL Injection — How to sanitize your user forms.

SQL injection… I hate this. I’ve been a victim of this once and it caused me a lot of work… (not too much, I just restored the database from the previous day). Anyway, since then I always use my general … Continue reading

Posted in Uncategorized | Comments Off on SQL Injection — How to sanitize your user forms.

How to check for EOF in MySQL

In ASP, I can check for an End-Of-File condition by using rs.EOF     ‘ returns True or False For example, if I’m verifying if a certain UserName exists in the database, I can do a SELECT * FROM query, and check … Continue reading

Posted in sql | Comments Off on How to check for EOF in MySQL

My first “real” PHP program! User Registration

I think I just created my first “real” PHP program. It’s a User Registration Form which does the following: checks if username entered is at least 4 char long the email address entered is valid format (but no checking if … Continue reading

Posted in Uncategorized | Comments Off on My first “real” PHP program! User Registration

MySQL $query format

In MySQL, you can create your query string like this: $query = “INSERT INTO NameDB (field1, field2, ….) VALUES (‘$value1’, ‘$value2’,….)”; Note that $values must be enclosed in quotes, otherwise you get an SQL error. In a way, this is … Continue reading

Posted in Uncategorized | Comments Off on MySQL $query format

Move to first record of table

In ASP, we use rs.MoveFirst In PHP, we need to use: // go back to top mysql_data_seek($result, 0);        // first row number is 0

Posted in Uncategorized | Comments Off on Move to first record of table