Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 11th, 2005, 09:40 AM
Registered User
 
Join Date: Nov 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Empty recordset = redirect

Is it possible to make a PHP code that redirect to another page if a recordset is EMPTY ??

If so - give an example please ;o)

Regards
Frank

Reply With Quote
  #2 (permalink)  
Old November 11th, 2005, 11:40 AM
Authorized User
 
Join Date: Nov 2005
Location: Houston, TX, .
Posts: 16
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via Yahoo to tonyrosen
Default

sure it is ...

<?
// make your database connection
// grab recordset
// check to see if the recordset is empy
if ($your_record_set is empty) {
    header("Location: /page.php");
} else {
    // work with the record set.
}
?>

The catch is that this has to be at the top of the page before browser headers are sent. Top lines, no whitespace above it and no HTML above it.

Reply With Quote
  #3 (permalink)  
Old November 12th, 2005, 04:49 AM
Registered User
 
Join Date: Nov 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thansk sir !
But i only get a blank page it do not redirect...

here is the code:

<?php
session_start();
$_SESSION['aktuel_uge'] = date("W")+1;
$_SESSION['uge'] = date("W");
?>
<?php
include("adminpro_class.php");
$prot=new protect();
if ($prot->showPage)
$curUser=$prot->getUser();
$_SESSION['user'] = date("W").$curUser ;
$curUser=$prot->getUser();
$_SESSION['userN'] = (date("W")+1).$curUser ;
$curUserV=$prot->getUserV();
$_SESSION['buy_v_user'] = $curUserV ;
{
?>
<?php require_once('Connections/DBZ.php');?>
<?php
// make your database connection
// grab recordset
$colname_Recordset2 = "1";
if (isset($HTTP_SESSION_VARS['userN'])) {
$colname_Recordset2 = (get_magic_quotes_gpc()) ? $HTTP_SESSION_VARS['userN'] : addslashes($HTTP_SESSION_VARS['userN']);
}
mysql_select_db($database_DBZ, $DBZ);
$query_Recordset2 = sprintf("SELECT * FROM userbuy WHERE uge = '%s'", $colname_Recordset2);
$Recordset2 = mysql_query($query_Recordset2, $DBZ) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
// check to see if the recordset is empy
if ($Recordset2 is empty) {
    header("Location: /bestillingsside1a.php");
} else {
    // work with the record set. - here come the rest of the pagecode
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Recordset Empty Check Coby Access VBA 2 April 27th, 2007 04:09 PM
Clone DAO Recordset into ADO Recordset kamrans74 VB How-To 0 March 6th, 2007 11:57 AM
Recordset empty when opening querydef DeAnzaJig Access VBA 3 November 14th, 2005 09:31 AM
ADODB.Recordset (0x800A0CB3)Current Recordset does tks_muthu Classic ASP Databases 0 June 16th, 2005 07:22 AM
Trap for empty recordset in a SP Mitch Access VBA 2 September 5th, 2003 04:47 PM



All times are GMT -4. The time now is 10:54 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.