Skip to content

Commit

Permalink
Suppress non-critical PHP errors
Browse files Browse the repository at this point in the history
The previous code contained various pieces that PHP usually executes
without complaints, but on some PHP installations it emits warnings.
This adds more checks that pretty much do what PHP would do anyway, but
without generating any errors.
  • Loading branch information
jast committed May 26, 2011
1 parent 7fe1026 commit 7f77e6f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions gen.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

$type = $_POST['type'];
$def = $_POST['def'];
$private = $_POST['private'] ? 1 : 0;
$type = isset($_POST['type']) ? $_POST['type'] : NULL;
$def = isset($_POST['def']) ? $_POST['def'] : NULL;
$private = isset($_POST['private']) ? ($_POST['private'] ? 1 : 0) : 0;

if ($type != 'graph' && $type != 'digraph')
die("Nuh-uh. Use one of the checkboxes.");
Expand All @@ -20,6 +20,7 @@ function get_one($q)
{
$res = mysql_query($q);
if (!$res) die("Failed to get stuff from database. Sorry!");
if (mysql_num_rows($res) == 0) return NULL;
return mysql_result($res, 0);
}
function id_shorten($id)
Expand Down
2 changes: 1 addition & 1 deletion get.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function id_lengthen($id)
return $res;
}

$id = $_GET['id'];
$id = isset($_GET['id']) ? $_GET['id'] : NULL;
if (!$id) die("No ID given.");
if (strlen($id) == 40)
$q = "graph_code = '".mysql_real_escape_string($id)."'";
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<p>Definition (without the surrounding <code>[di]graph {}</code> thing): (<a
href="http://en.wikipedia.org/wiki/DOT_language">syntax</a>, <a
href="index.php?example=1">example</a>)<br>
<textarea name="def" rows="20" cols="50"><?php if ($_GET['example']):
<textarea name="def" rows="20" cols="50"><?php if (isset($_GET['example']) && $_GET['example']):
?>Sleep -&gt; Work [label="zombie"]
Work -&gt; TV [label="zombie"]
TV -&gt; Sleep [label="zombie"]
Expand Down

0 comments on commit 7f77e6f

Please sign in to comment.