Bug #15790: Getting Parse error when trying to access page. I believe it's related to mysql
| From: | jasonr at dream2create dot com | Date: | Thu, 28 Feb 2002 19:20:42 +0000 |
| Subject: | Bug #15790: Getting Parse error when trying to access page. I believe it's related to mysql | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-1313@lists.php.net to get a copy of this message | ||
From: jasonr@dream2create.com
Operating system: Mac OS 10.1.3 (Darwin 5.3)
PHP version: 4.1.2
PHP Bug Type: MySQL related
Bug description: Getting Parse error when trying to access page. I believe it's related to
mysql
OS: Mac OS 10.1.3
Apache: 1.3.22 (DARWIN)
PHP: 4.1.2
mySQL: 3.23.48
This is the error I get when I try to accecss the page:
"Parse error: parse error in /Library/WebServer/Documents/
timemanagement/billing.php on line 2"
Code:
<?php
$db = mysql_connect ("localhost", "user", "password");
mysql_select_db ("database", $db);
if ($submit) {
if ($clientsubmit) {
$sql = "
INSERT INTO client (client)
VALUES ('$newclient')
";
$result = mysql_query($sql);
} else if ($submitbill) {
$sql = "
INSERT INTO billing (employee, client, job_
type, time_spent, billable, description, wage)
VALUES ('$employee', '$client',
'$jobtype',
'$timespent', '$billable', '$desc', '$wage')
";
$result = mysql_query($sql);
echo "Thank you for your entry, <a href=
'billing.php?employee=$employee'>click here</
a> to enter another.</a>";
exit;
}
?>
<html>
<head>
<title>Billing</title>
</head>
<body>
<form method="POST" action="billing.php">
<table>
<tr>
<td>Client</td>
<td>Job Type</td>
<td>Time Spent (hrs)</td>
<td>Wage</td>
<td>Billable</td>
<td>Description</td>
</tr>
<tr>
<td>
<select name="client">
<?php
$sql = "
SELECT id, client
FROM client
";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result))
{
$client = $row["client"];
$id = $row["id"];
echo "<option value='$id'>$client</option>";
}
?>
</select>
</td>
<td>
<select name="jobtype">
<option value="Support">Technical
Support</option>
<option value="Programming">
Programming</option>
<option value="Accounting">Accounting</
option>
<option value="Consulting">
Consultation</option>
</select>
</td>
<td>
<input type="text" name="timespent" size=
"4">
</td>
<td>
<select name="wage">
<option value="20">$20 x hr</option>
<option value="40">$40 x hr</option>
<option value="60">$60 x hr</option>
<option value="80">$80 x hr</option>
<option value="100">$100 x hr</option>
</select>
</td>
<td>
<select name="billable">
<option value="1">Yes</option>
<option value="2">No</option>
</select>
</td>
<td>
<textarea name="desc"></textarea>
</td>
</tr>
<tr>
<td colspan="5">
<input type="hidden" name="employee" value=
"<?php echo $employee;?>">
<input type="hidden" name="submit" value=
"1">
<input type="submit" name="submitbill"
value="Submit Billing">
</td>
</tr>
</table>
</form>
<br><br>
<hr>
<form method="POST" action="billing.php">
Add new client: <input type="text" name="newclient">
<input type="hidden" name="employee" value="<
?php echo $employee;?>">
<input type="hidden" name="submit" value="1">
<input type="submit" name="clientsubmit" value="Submit
New Client">
</form>
<?
} /* End of if ($submit) */
else
{
$employees = array ("Patrick", "Avi", "Sara", "Jess
ica", "Tasha", "Vegi");
$j = count ($employees);
?>
<form method='POST' action='billing.php'>
<select name='employee'>
<?php
for ($i = 0; $i < $j; $i++) {
echo "<option value='{$employees[$i]}'>
{$employees[$i]}</option>";
}
?>
</select>
<input type='submit' name='submit'>
</form>
<?php
}
?>
</body>
</html>
--
Edit bug report at http://bugs.php.net/?id=15790&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=15790&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=15790&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=15790&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=15790&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=15790&r=support
Expected behavior: http://bugs.php.net/fix.php?id=15790&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=15790&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=15790&r=submittedtwice