Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If everyone could sign this (and Relsoft, take a look ;*) )
#11
Quote:
Code:
// Define sql

$sql = "SELECT foo, joe AS bar
  FROM blah
  WHERE condition
  AND other_condition
  LIMIT number, number";

// Do query
if ( !$result = @mysql_query( $sql ) )
{
  // die, with nice, formatted output. I suggest a function for this
  die('
Database Query Error!

' . mysql_error() . '
$sql
Line: ' . __LINE__ . ', File: ' . __FILE__);
}

// Get each result, and store it in $row as we go
while ( $row = mysql_fetch_array( $result ) )
{
  // Do what you will with each result
  $foo = $row['foo'];
  $joe = $row['bar'];  // Note, the AS bar clause means joe is in bar
}

[end oracle's quick db tutorial]

Wink

You may not be aware of this, but not all SQL databases use the same logical operators.

I run mySQL and it doesn't like 'AND', rather, it uses the C-Style operator 'f '&&'.

[end 1000101's quick note on oracle's quick db tutorial]
Life is like a box of chocolates', hrm, WTF, no it isn't, more like, 'life is like a steaming pile of horse crap.'
Reply


Messages In This Thread
If everyone could sign this (and Relsoft, take a look ;*) ) - by 1000101 - 02-20-2004, 05:18 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)