rurbaniak
10-12-2004, 06:52 PM
Ok, I'm new to PHP/MYSQL, but have been messing around with it. So with one of my test files, I wanted to see if it would work in Soholaunch 4.6 as a custom code file. It's a simple file that returns all the entries in the table, and each is hyperlinked. You click on it, and you are able to edit it. Here, it is: http://www.pcandnetworking.com/indb3.php
So, I dropped it into Soho 4.6 as a custom code in one of my pages and Soho doesn't like it: Here it is. (http://demo.revolutionsolutions.net/index.php?customernumber=136337109716289&pr=Test)
Here is the code from the PHP file as well:
<html>
<body>
<?php
$db = mysql_connect("localhost", "dbuser", "password");
mysql_select_db("dbname",$db);
if ($id) {
if ($submit) {
$sql = "UPDATE employees SET first='$first',last='$last',address='$address',pos ition='$position' WHERE id=$id";
$result = mysql_query($sql);
echo "Thank you! Information updated.\n";
} else {
// query the DB
$sql = "SELECT * FROM employees WHERE id=$id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>
<form method="post" action="<?php echo $PHP_SELF?>">
<input type=hidden name="id" value="<?php echo $myrow["id"] ?>">
First name:<input type="Text" name="first" value="<?php echo $myrow["first"] ?>"><br>
Last name:<input type="Text" name="last" value="<?php echo $myrow["last"] ?>"><br>
Address:<input type="Text" name="address" value="<?php echo $myrow["address"] ?>"><br>
Position:<input type="Text" name="position" value="<?php echo $myrow["position"] ?>"><br>
<input type="Submit" name="submit" value="Enter information">
</form>
<?php
}
} else {
// display list of employees
$result = mysql_query("SELECT * FROM employees",$db);
while ($myrow = mysql_fetch_array($result)) {
printf("<a href=\"%s?id=%s\">%s %s</a><br>\n", $PHP_SELF, $myrow["id"], $myrow["first"], $myrow["last"]);
}
}
?>
</body>
</html>
So, is there a way to fix this?? Thanks
So, I dropped it into Soho 4.6 as a custom code in one of my pages and Soho doesn't like it: Here it is. (http://demo.revolutionsolutions.net/index.php?customernumber=136337109716289&pr=Test)
Here is the code from the PHP file as well:
<html>
<body>
<?php
$db = mysql_connect("localhost", "dbuser", "password");
mysql_select_db("dbname",$db);
if ($id) {
if ($submit) {
$sql = "UPDATE employees SET first='$first',last='$last',address='$address',pos ition='$position' WHERE id=$id";
$result = mysql_query($sql);
echo "Thank you! Information updated.\n";
} else {
// query the DB
$sql = "SELECT * FROM employees WHERE id=$id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>
<form method="post" action="<?php echo $PHP_SELF?>">
<input type=hidden name="id" value="<?php echo $myrow["id"] ?>">
First name:<input type="Text" name="first" value="<?php echo $myrow["first"] ?>"><br>
Last name:<input type="Text" name="last" value="<?php echo $myrow["last"] ?>"><br>
Address:<input type="Text" name="address" value="<?php echo $myrow["address"] ?>"><br>
Position:<input type="Text" name="position" value="<?php echo $myrow["position"] ?>"><br>
<input type="Submit" name="submit" value="Enter information">
</form>
<?php
}
} else {
// display list of employees
$result = mysql_query("SELECT * FROM employees",$db);
while ($myrow = mysql_fetch_array($result)) {
printf("<a href=\"%s?id=%s\">%s %s</a><br>\n", $PHP_SELF, $myrow["id"], $myrow["first"], $myrow["last"]);
}
}
?>
</body>
</html>
So, is there a way to fix this?? Thanks