Jump to content
php.lv forumi

php switch


false

Recommended Posts

Erors:

Notice: Undefined index: p in C:\xampp\xampp\htdocs\index.php on line 77

Viss kods (77.rinda ir switch ($_REQUEST['p']) {)

<?php            
switch ($_REQUEST['p']) {
case 'news':
if(!isset($_SESSION['id']))
{
}
if(isset($_SESSION['id']))
{
$time_sw = time();
$updeit = mysql_query("UPDATE lietotaaji SET pedeja_akt=".$time_sw." AND SET time=".$time_sw." WHERE id=".$id."");
}
include_once('news.php');
break;
case 'forum':
if(!isset($_SESSION['id']))
{
}
default:
$time_sw = time();
$updeit = mysql_query("UPDATE lietotaaji SET time=".$time_sw."");
include_once('news.php');
break;
}    
?>

Meiģināju likt šadi:

switch (isset($_REQUEST['p'])) {

Tad vispār neiet tās switch

Tad vēl šadi:

if(($_REQUEST['p'])){
switch ($_REQUEST['p']) {
...
}}

Arī negāja..

Kāds var palīdzet atrisināt šo problēmu?

Link to comment
Share on other sites

Reāli tas ir tikai notice, kas nav nekas traks. Lai nu kā:

  • $_REQUEST vietā es ieteiktu rakstīt vai nu $_GET vai $_POST, atkarībā kas tad tev īsti tika dots
  • lai atkratītos no notice, vari darīt tā:

$p = (isset($_REQUEST['p']) ? $_REQUEST['p'] : "";
switch($p) {
// te tas pats, kas tavā kodā
}

 

Būtībā notice saka, ka tas masīvā $_REQUEST neeksistē elements ar indeksu p.

Link to comment
Share on other sites

Reāli tas ir tikai notice, kas nav nekas traks. Lai nu kā:

  • $_REQUEST vietā es ieteiktu rakstīt vai nu $_GET vai $_POST, atkarībā kas tad tev īsti tika dots
  • lai atkratītos no notice, vari darīt tā:

$p = (isset($_REQUEST['p']) ? $_REQUEST['p'] : "";
switch($p) {
// te tas pats, kas tavā kodā
}

 

Būtībā notice saka, ka tas masīvā $_REQUEST neeksistē elements ar indeksu p.

 

Parse error: syntax error, unexpected ';' in C:\xampp\xampp\htdocs\index.php on line 77

77.rinda:

$p = (isset($_REQUEST['p']) ? $_REQUEST['p'] : "";

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...