notice

Notice : Undefined variable when concatenating

落爺英雄遲暮 提交于 2019-11-29 17:28:45
I have been making a script to display users and make changes to their admin privileges. Here is the code: while ($row= mysql_fetch_assoc($query)) { $uname= $row['username']; $fname= $row['first_name']; $lname= $row['last_name']; $email= $row['email']; $admin= $row['admin']; $insert .= '<tr> <td>' .$uname. '</td> <td>' .$fname. '</td> <td>' .$lname. '</td> <td>' .((isset($email)) ? $email:'No email set.'). '</td> <td>'.(($admin == 'y') ? 'Admin':'User').'</td> <td><input type="checkbox" name="' .$uname. '" value="'.(($admin == 'y')?'n':'y').'"/>'.(($admin == 'y')?'Make a user':'Make an admin

Is it alright to suppress/hide PHP notices?

纵饮孤独 提交于 2019-11-29 06:02:42
问题 I've suppressed notices for quite some time with no problems whatsoever but I am beginning to wonder if I'm doing the right thing. I can't seem to find any logical reason why I shouldn't just suppress them but some other people seem to think that suppressing them using error_reporting is a horrible thing to do, but why? The closest thing to an answer I could find was in this question but that's still far from the answer I'm looking for. Is there some sort of unforeseen downside to hiding all

PHP: Undefined offset

别说谁变了你拦得住时间么 提交于 2019-11-28 05:38:45
问题 On some pages, i receive the error: PHP Notice: Undefined offset: 1 in /var/www/example.com/includes/head.php on line 23 Here is the code: if ($r) { list($r1, $r2)=explode(" ", $r[0],2); $r1 = mb_strtolower($r1); $r3 = " "; $r2 = $r3.$r2; $r[0] = $r1.$r2; $page_title_f = $r[0]." some text"; $page_title_s = "some text "; $page_title = $page_title_s.$page_title_f; } Line 23 with error: list($r1, $r2)=explode(" ", $r[0],2); Could you help to understand what could be the problem? Update Thanks

Check if Variable exists and === true

烂漫一生 提交于 2019-11-28 01:49:20
I want to check if: a field in the array isset the field === true Is it possible to check this with one if statement? Checking if === would do the trick but a PHP notice is thrown. Do I really have to check if the field is set and then if it is true? If you want it in a single statement : if (isset($var) && ($var === true)) { ... } If you want it in a single condition : Well, you could ignore the notice (aka remove it from display using the error_reporting() function). Or you could suppress it with the evil @ character: if (@$var === true) { ... } This solution is NOT RECOMMENDED I think this

Check if Variable exists and === true

淺唱寂寞╮ 提交于 2019-11-26 22:00:38
问题 I want to check if: a field in the array isset the field === true Is it possible to check this with one if statement? Checking if === would do the trick but a PHP notice is thrown. Do I really have to check if the field is set and then if it is true? 回答1: If you want it in a single statement : if (isset($var) && ($var === true)) { ... } If you want it in a single condition : Well, you could ignore the notice (aka remove it from display using the error_reporting() function). Or you could

Notice: Trying to get property of non-object error

↘锁芯ラ 提交于 2019-11-26 12:25:52
i am trying to get data from: http://api.convoytrucking.net/api.php?api_key=public&show=player&player_name=Mick_Gibson but if i want to get player_name variable with this code: <? $js = file_get_contents('http://api.convoytrucking.net/api.php?api_key=public&show=player&player_name=Mick_Gibson'); $pjs = json_decode($js); var_dump($pjs->{'player_name'}); ?> i get error: Notice: Trying to get property of non-object in **\htdocs\index.php on line 9 + var_dump() returns: NULL var_dump($pjs) returns: array(1) { [0]=> object(stdClass)#52 (15) { ["player_name"]=> string(11) "Mick_Gibson" ["player_id"]

Notice: Trying to get property of non-object error

拜拜、爱过 提交于 2019-11-26 02:58:06
问题 i am trying to get data from: http://api.convoytrucking.net/api.php?api_key=public&show=player&player_name=Mick_Gibson but if i want to get player_name variable with this code: <? $js = file_get_contents(\'http://api.convoytrucking.net/api.php?api_key=public&show=player&player_name=Mick_Gibson\'); $pjs = json_decode($js); var_dump($pjs->{\'player_name\'}); ?> i get error: Notice: Trying to get property of non-object in **\\htdocs\\index.php on line 9 + var_dump() returns: NULL var_dump($pjs)