php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15790 Getting Parse error when trying to access page. I believe it's related to mysql
Submitted: 2002-02-28 14:20 UTC Modified: 2002-03-01 11:16 UTC
From: jasonr at dream2create dot com Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 4.1.2 OS: Mac OS 10.1.3 (Darwin 5.3)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jasonr at dream2create dot com
New email:
PHP Version: OS:

 

 [2002-02-28 14:20 UTC] jasonr at dream2create dot com
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>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-28 17:28 UTC] mfischer@php.net
Please give a SHORTER example of the code which doesn't work. 

Anyway, if that's the file billing.php, then the line 2 would be the empty one ...
 [2002-02-28 21:07 UTC] jasonr at dream2create dot com
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"

When I moved the "$db = mysql_connect..." line (whether up 
or down) the line error changes accordingly. I have another 
page with a similar beginning and it is getting the same 
error.

Code from billing.php:
<?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;? 
????????}? 
?>?
 [2002-03-01 03:43 UTC] sander@php.net
The bug system is not the appropriate forum for asking support
questions. For a list of a range of more appropriate places to ask
for help using PHP, please visit http://www.php.net/support.php


 [2002-03-01 11:16 UTC] jasonr at dream2create dot com
I didn't write this code. I copied it from an example which 
is why I'm confused why it is not working.

I was curious if it would work for other people, because 
maybe it's a problem with Darwin. Being that my version of 
MySql is not the newest and I don't have a full version of 
Apache.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 13 14:01:28 2025 UTC