LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 730 users online 211451 members 1286 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Memberlist | Dictionary | News | FAQ
Member Spotlight
Doubleshift
Music: Rock, indie, alternative, etc.
Mood: Down
You have 1 new message.
Emergency Help
Until you sign up you can't do much. Yes, it's free.

Sign Up Now
Membername:
Password:
Already have an account?
Invite Friends
Active Members
Groups
Contests
Moderators
9 online / 22 MPM
Fresh Topics
  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic

[php] if a database entry does not exist
can anyone help?
Replies: 6Last Post Feb. 12, 2007 1:10pm by pleaseremove
Welcome to LiveWire!
We're Stronger Together.
Join the Community
Single page for this topic Email Print Favorite
( Bestm8ts )


Wealthy Hobo
Reply
getting pageID
Code:

$pageid = $_GET['id'];

if($pageid == '') {$pageid = 'home';}

Database connection
Code:

include ('db_connect.php');
$query = "SELECT * FROM pages WHERE id='".$pageid."'";
$result = mysql_query($query);
$num = mysql_numrows($result);
mysql_close();

ok so the above code gets a page id from the url and uses that to get info from a database.. ive included an if statement to account for times when people go to the base dir without the tag call..

what i want to be able to do is create an statement to account for times when people put in an invalid pageid, the code would look in the database and obvously if the pageID is wrong nothing will come back, i wana write something that states if database call is false post a code which will display a 404 error..
if (database = "") {$pageid = 'error'};

the if 'database' is just to illustrate the point..

anyone know how to check if a databse call is false?


7:20 am on Feb. 12, 2007 | Joined: May 2005 | Days Active: 288
Join to learn more about Bestm8ts England, United Kingdom | Posts: 1,307 | Points: 4,030
Single page for this topic Email Print Favorite

Quick Reply

You are signed in as our guest.

Looking for something else?
 

  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic