LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 609 users online 225613 members 1572 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Memberlist | Dictionary | News | FAQ
Member Spotlight
feeltheshane
You'll always be beautiful in my eyes.
Mood: Frustrated
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
3 online / 52 MPM
Fresh Topics
  LiveWire / Technical Forums / Programming & Application Development / Adding Reply

Quoting Post
Archived Topic: It will not be bumped to the top of the forum.
Topic [php] if a database entry does not exist
Membername   Not a member? Sign Up Free (takes 20 seconds)
Password   Forgotten your password?
Post

Font:   Size:   Color:

FAQ Keyword Search:
Post Options
Favorites Manager
Notify me of new replies to this topic by email
Notify me of new replies to this topic by private message
Original Post
Bestm8ts Posted at 7:20 am on Feb. 12, 2007
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?

Replies
Bestm8ts Posted at 7:20 am on Feb. 12, 2007
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?

All 6 previous replies displayed.