Jump to content


Photo

Notice: Undefined index: AND Notice: Undefined variable:


  • Please log in to reply
3 replies to this topic

#1 DaveLinger

DaveLinger
  • Members
  • PipPipPip
  • Advanced Member
  • 268 posts
  • LocationWV, USA

Posted 15 September 2006 - 08:09 PM

I'm getting both of these errors now that I've switched to a new server. The code it doesn't like is...

<?php
if($_GET['page'] == ''){
$id="index";
}else{
$id = $_GET['page'];
}
?>

http://www.DaveLinger.com
dave at linger dot com

#2 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 15 September 2006 - 08:14 PM

That should work
A little tip to make it cleaner

$id = isset($_GET["page"]) ? $_GET["page"] : "index";

try usin the isset();
Tell me the problem, I will try tell you the solution

#3 DaveLinger

DaveLinger
  • Members
  • PipPipPip
  • Advanced Member
  • 268 posts
  • LocationWV, USA

Posted 15 September 2006 - 08:24 PM

what about for something like this?

if($id == ''){
$query="SELECT *, DATE_FORMAT(Date, '%W, %M %D %Y') AS my_date FROM wg_pages WHERE id=\"$id2\" ORDER BY datetime DESC";
}else{
$query="SELECT *, DATE_FORMAT(Date, '%W, %M %D %Y') AS my_date FROM wg_pages WHERE id=\"$id\" ORDER BY datetime DESC";
}

http://www.DaveLinger.com
dave at linger dot com

#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 15 September 2006 - 08:32 PM

Depends on whether $id has previously been defined or not .
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users