Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php & html error 1

Status
Not open for further replies.

yamy

Technical User
Nov 22, 2002
54
0
0
US
I am happy for your review and suggestions to troubleshoot this little problem of mine:

I suspect either the script or html returns this Firefix browser error message:
The server encountered an unexpected condition which prevented it from fulfilling the request.
The script had an error or it did not produce any output. If there was an error, you should be able to see it in the error log.

the error log shows this message:

"uncaught exception:permission denied to call method Location.toString"

IE returns the same browser message but I cannot find the error log to see what it says.

here is the snippet of code from the web page. I pulled it from a book i am using to learn mysql and maybe there is a typo that I am too much a novice to see (yet).

Thanks
Yamy


<form method="get" action="add.php">
companyName: <input type="text" name="companyName">
contactName: <input type="text" name="contactName">
phone: <input type="text" name="phone">
<input type="submit" name="add" value="submit">
</form>

<?php

if($add) {
mysql_connect("mysql.someserver.com", "user", "password");
mysql_select_db("dlr");
$query="insert into company (companyName, contactName, phone)";
$query.=" values('$companyName','$contactName','$phone')";
$result=mysql_query($query);
if ($result) echo "<b>added one row successfully.</b>";
}
?>
 
It seems like me to be an Javascript error, and there is no Javascript, so my guess would be: spyware ??

 
i agree with elck. the location.to looks suspiciously javascripty. thus spyware/virus likely culprits.

as dhagaxtuur also pointed out, the code is flawed too. looks like it was written for a register_globals environment and it also lacks escaping etc (although this is probably/hopefully in a later chapter of the OP's guide book).

to the OP: download and install firefox and the web developer's toolbar. turn off javascript and try your code again. be sure to use dhagaxtuur's mod as i'd bet that your php.ini file has register globals switched off.
 
thanks for the help and the link to useful sites!

 
the insert query does not work in the form handler script.

try the links to see how i partially succeed with query $var and db connections.

here is the link to the form -
the code for the form -

<form method="post" action="add_final_test_form.php">
<input type="text" name="companyName" value="companyName" />
<input type="submit" name="submit" value="submit" />

</form><hr />

<?php
mysql_connect("mysql.fatcow.com","amytestdb","guest");
mysql_select_db("amy_test_db");
$result = mysql_query("select companyName from test_table");
while (list($companyName) = mysql_fetch_row($result)) {
echo "<p>$companyName</p>";
}
echo "<hr />a list of company names above will prove the db connect. A select query displays names entered directly via mysql gui. when the handler script works, this list should grow with each entry";
?>

here is the handler script -
<?php
$companyName = $_REQUEST['companyName'];

if (isset($_POST['submit'])) {
mysql_connect("mysql.fatcow.com", "amytestdb", "guest");
mysql_select_db("amy_test_db");
$query="INSERT INTO test_table ('companyName')";
$query.=" VALUES('$companyName')";
$result=mysql_query($query);
if ($result) echo "added one record successfully";
else echo "error";
}

?>
<hr /><p>form handling page - </p><p>should show "record successfully added" or "error".</p><hr />
<?php
echo "you entered the company name \"$companyName\", thank you. <p>the company name shown in this sentence was generated with a declared PHP variable. </p>the same value is being declared for the query (insert into table...) that fails";
?>

i will continue to search for the solution but all help appreciated from your fresh views and experience.

many thanks
 
added note
typical of my php experience, now it is all broken again.
i realized i had posted db access in my posting so i went to add a new user, assign new user access to db and now no access works except direct thru the mysql gui.
i don't know how to help me now!
 
almost always it is a mis-placed or mis-used single or double quote.
what a challenge to keep those rules straight.

thanks for listening, i've got this on the run now!

regards,

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top