Learning PHP and MySQL

Wednesday, September 27, 2006

Example 16-8 SQL to create the users table (may have already been created

CREATE  TABLE  `users`  (
    `
user_id`  int(11)  NOT  NULL  auto_increment,
    `
first_name`  varchar(100)  NOT  NULL,
    `
last_name`  varchar(100)  NOT  NULL,
    `
username`  varchar(45)  NOT  NULL,
    `
password`  varchar(32)  NOT  NULLPRIMARY  KEY    (`user_id`));

SQL code returns, again, that the query value was OK.

Query OK0 rows affected (0.02  sec)

Posted by krautgrrl on 09/27 at 11:40 AM
Chapter 16 Code • (4) Comments • (1) TrackbacksPermalink

Example 16-9 Inserting sample data for the tables

INSERT  INTO  categories  VALUES  (1,'Press  Releases'); INSERT  INTO  categories  VALUES  (2,'Feature  Requests');

INSERT  INTO  posts  VALUES  (NULL,1,1,'PHP  Version  12','PHP  Version  12,  to  be released  third  quarter  2006.  Featuring  the  artificial  inteligence  engine  that writes  the  code  for  you.',NULL);
INSERT  INTO  posts  VALUES  (NULL,1,1,'MySQL  Version  8','Returns  winning  lotto number.',NULL);
INSERT  INTO  posts  VALUES  (NULL,2,2,'Money  Conversion','  Please  add  functions for  converting  between  foreign  currentcies.  ',NULL);

INSERT  INTO  comments  VALUES  (NULL,1,1,'Correction','Release  delayed  till  the year  2099',NULL);

INSERT  INTO  users  VALUES  (NULL,'Michele','Davis','mdavis',md5('secret')); INSERT  INTO  users  VALUES  (NULL,'Jon','Phillips','jphillips',md5('password'));

You should see a result similar to the one below for each of the INSERT SQL commands.

Query OK1 row affected1 warning (0.03  sec)

Posted by krautgrrl on 09/27 at 11:41 AM
Chapter 16 Code • (2) Comments • (4) TrackbacksPermalink

Example 17-1 File comments

/*
*
*  this  file  is  about  furniture  stores.
*  this  file  is  about  furniture  stores  in  Minnesota,  Wisconsion,  Iowa  and  Illinois.
*
*  Portions  Copyright  2005-2006  (c)  O’Reilly  &  Associates
*  The  rest  Copyright  2005  (c)  from  their  respective  authors
*
*  @version    $Id:  coding_standards.html,v  1.2  2005/12/19  24:49:50
*
*/

Posted by krautgrrl on 09/27 at 12:36 PM
Chapter 17 Code • (0) Comments • (3) TrackbacksPermalink

Example 17-2 Function comments

/*
*  furniture  stores  locator.
*  Locate  furniture  stores  in  Minnesota,  Wisconsion,  Iowa  and
*  Illinois  based  on  their  zip  code.
*
*  @author    michele  davis  mdavis@example.com
*  @param    zipcode    the  zipcode  to  search  for  stores  near
*  @return    store    the  store  id  of  the  nearest  store
*  @date    2005-12-21
*
*/

Posted by krautgrrl on 09/27 at 12:39 PM
Chapter 17 Code • (0) Comments • (4) TrackbacksPermalink

Wednesday, July 19, 2006

Example 3-21 Echoing the line and file predefined constants for a script called predefined_constants

<?php
echo  "Executing  line  ".    __LINE__  .  "  of  PHP  script  "  .  __FILE__  .  '.';
?>

Returns:

Executing line 2 of PHP script /home/www/html/oreilly/ch3/predefined_constants.php.

Posted by krautgrrl on 07/19 at 03:57 PM
Chapter 3 Code • (0) Comments • (1067) TrackbacksPermalink

Friday, August 18, 2006

Figure 10-03 Text boxes

<form>
<
input  type="text"  name="search"  size="10"  maxlength="30"  />
</
form>

This creates the Figure 10-03 in the Learning PHP & MySQL book.

Posted by krautgrrl on 08/18 at 10:56 AM
Chapter 10 Code • (0) Comments • (1204) TrackbacksPermalink

Figure 10-04 A simple form with a text area element

<form>
<
label>Suggestion:  <textarea  name="suggestions"  cols="40"  rows="5"></textarea>
</
label>
<
input  type="submit"  value="Go!  />
</form>

This creates the example in Figure 10-04 in the book.

Posted by krautgrrl on 08/18 at 10:58 AM
Chapter 10 Code • (0) Comments • (0) TrackbacksPermalink

Figure 10-05 Checkboxes

<form>
<
fieldset>
<
label>Italian  <input  type="checkbox"  name="food[]"  value="Italian"  /></label>
<
label>Mexican  <input  type="checkbox"  name="food[]"  value="Mexican"  /></label>
<
label>Chinese  <input  type="checkbox"  name="food[]"  value="Chinese"
checked="checked"  /></label>
</
fieldset>
<
input  type="submit"  value="Go!  />
</form>

This code displays Figure 10-05 in the book.

Posted by krautgrrl on 08/18 at 10:59 AM
Chapter 10 Code • (0) Comments • (0) TrackbacksPermalink

Figure 10-06 Radio buttons

<form>
<
fieldset>
<
label>Italian  <input  type="radio"  name="food"  value="Italian"  /></label>
<
label>Mexican  <input  type="radio"  name="food"  value="Mexican"  /></label>
<
label>Chinese  <input  type="radio"  name="food"  value="Chinese"
checked="checked"    /></label>
</
fieldset>
<
input  type="submit"  value="Go!  />
</form>

This code generates the example in Figure 10-06 in the book.

Posted by krautgrrl on 08/18 at 11:00 AM
Chapter 10 Code • (12) Comments • (0) TrackbacksPermalink

Figure 10-09 Selecting Italian and Chinese

<html>
<
head>
   <
title>Using  Default  Checkbox  Values</title>
</
head>
<
body>
<?
php
$food
=$_GET[food];
$self=$_SERVER['PHP_SELF'];
if  (!empty(
$food))
{
   
echo  "The  foods  selected  are:<br  />";
   foreach(
$_GET[food]  as  $foodstuf)
   
{

      }
   }
else
{
   
echo  ("<form  action=\"$self\"  ");
   echo  (
'method="get">
   <fieldset>
     <label>Italian  <input  type="checkbox"  name="food[]"  value="Italian"  /></label>
     <label>Mexican  <input  type="checkbox"  name="food[]"  value="Mexican"  /></label>     
     <label>Chinese  <input  type="checkbox"  name="food[]"  value="Chinese"
checked="checked"  /></label>
     </fieldset>
       <input  type="submit"  value="Go!"  >
             '
);
}
?>
</body>
</html>

This code displays the graphic Figure 10-09 in the book.

Posted by krautgrrl on 08/18 at 11:03 AM
Chapter 10 Code • (19) Comments • (4) TrackbacksPermalink

Thursday, July 06, 2006

Googling now a verb!

’The Oxford English Dictionary (OED), which bills itself as “The definitive record of the English language,” added the company name as a verb in the latest round of updates, placing Google in such august company as FedEx, TiVo, and Xerox.’

Taken from this article: Googling

Posted by krautgrrl on 07/06 at 09:10 AM
Blogging • (0) Comments • (1) TrackbacksPermalink

PHP Variable

<?php 
$age 
30
?>

Then reassign the value with:

<?php 
 $age 
30
 
$age 31;
 echo 
$age;
?>

You should get the new $age as 31.

Posted by krautgrrl on 07/06 at 02:40 PM
(0) Comments • (669) TrackbacksPermalink

Thursday, August 03, 2006

Question 05-01 What’s wrong with this function call?

This code is for Question 5-1.

<?php
//  define  a  function 
function  Response  {
  
echo  "Have  a  good  day!<br/><br/>";
}

//  driving  to  work
echo  "Are  you  going  to  merge?  <br/>"
Response;

//  at  the  office
echo  "I  need  a  status  report  on  all  your  projects  in  the  next  10  minutes  for  my management  meeting.<br/>";
Response;

//  at  the  pub  after  work
echo  "Did  Bill  get  everything  he  needed  today?  He  was  sure  crabby!<br/>"
Response;
?>

Posted by krautgrrl on 08/03 at 08:27 AM
Chapter 5 Code • (3) Comments • (0) TrackbacksPermalink

Monday, September 25, 2006

SQL Injection

1,1);drop table users;. When this query is added to a query like this:

$query  =  "INSERT  INTO  ‘books’  VALUES  (NULL,$title,$pages)";

Here’s what could happen:

$query  =  "INSERT  INTO  ‘books’  VALUES  (NULL,1,1);drop  table  users;  ,$pages)";

Posted by krautgrrl on 09/25 at 11:08 AM
Chapter 12 Code • (0) Comments • (0) TrackbacksPermalink
Page 15 of 15 pages « First  <  13 14 15

Statistics

This page has been viewed 374245 times
Page rendered in 0.1951 seconds
Total Entries: 224
Total Comments: 16
Total Trackbacks: 307338
Most Recent Entry: 09/27/2006 12:39 pm
Most Recent Comment on: 10/26/2007 10:00 am
Total Members: 2
Total Logged in members: 0
Total guests: 13
Total anonymous users: 0
Most Recent Visitor on: 02/06/2012 06:44 am
The most visitors ever was 1103 on 11/20/2007 12:50 pm

Referrers

Powered by ExpressionEngine