Jump to content

Please Help Me. My Code Isn't Working


timmah1

Recommended Posts

I am hosting at dreamhost, I just recently switched from gatorhost.

 

This code worked fine at gatorhost, but it don't do anything at dreamhost.

 

Can you see something wrong?

<table width="500" border="0" cellpadding="0" cellspacing="0" class="text">
  <tr>
    <td rowspan="2" valign="top"><?php 
include "DB_config.php";

if ($update =="yes")
{
$query="update about set content='$_POST[content]' where id = '$id'";
$result2 = MYSQL_QUERY($query);
echo "About Us page has been updated";

}
else {
$user = "SELECT * FROM about";
$result = mysql_query($user);

$numberall = mysql_Numrows($result);
while($row = mysql_fetch_array( $result )){
?>

<h3>About Us Page</h3>
<br />
<form action="" method="post" name="about" id="about">

<table width="100%" border="0" cellspacing="0" cellpadding="5">
  <tr>
    <td><textarea name="content" cols="80" rows="25" id="main"><? echo "$row[content]"; ?></textarea></td>
    </tr>
  <tr>
    <td><input type="hidden" name="update" value="yes" />
        <input type="submit" name="update" value="Update" /></td>
    </tr>
</table>
</form>
<?

}
}

?> 
</td>
   
  </tr>
</table>

 

Thank you in advance

Link to comment
Share on other sites

<table width="500" border="0" cellpadding="0" cellspacing="0" class="text">

  <tr>

    <td rowspan="2" valign="top"><?php

include "DB_config.php";

 

if ($update =="yes")

{

$query="update about set content='$_POST[content]' where id = '$id'";

$result2 = mysql_query($query);

echo "About Us page has been updated";

 

}

else {

$user = "SELECT * FROM about";

$result = mysql_query($user);

 

$numberall = mysql_numrows($result);

while($row = mysql_fetch_array( $result )){

?>

 

<h3>About Us Page</h3>

<br />

<form action="" method="post" name="about" id="about">

 

<table width="100%" border="0" cellspacing="0" cellpadding="5">

  <tr>

    <td><textarea name="content" cols="80" rows="25" id="main"><? echo "$row[content]"; ?></textarea></td>

    </tr>

  <tr>

    <td><input type="hidden" name="update" value="yes" />

        <input type="submit" name="update" value="Update" /></td>

    </tr>

</table>

</form>

<?

 

}

}

 

?>

</td>

 

  </tr>

</table>

try the above

 

or u have found no content in the page??

 

if the second one then please check the database configuration correctly.

 

 

 

Thanks

--

Tapos Pal

 

Link to comment
Share on other sites

Also the mysql functions should be all lowercase.

 

Built in functions are case insensitive.

 

Might be register globals. Make sure dreamhost has them turned on.

 

Do not encourage the use of register_globals, it is being made extinct for a reason.

 

Change this line...

 

if ($update =="yes")

 

to...

 

if ($_POST['update'] =="yes")

 

And see how that goes.

Link to comment
Share on other sites

The biggest two reasons to not use register globals are - 1) They have been completely eliminated in php6. If you want your code to work when php6 is released, you WILL need to eliminate all dependences on register globals. 2) They were a huge blunder and in one case allows external data (POST/GET) to put values into program variables that normally come from session data. (Allowing you to do things like appear to be logged in or appear to be administrators in publicly released scripts where program variable names are known that get set through register globals from session data.)

 

Register globals were turned off by default in php4.2 in the year 2002. No new code, books, tutorials... should have been written after that point in time that rely on register globals, and no one should be suggesting in 2007/2008 that turning them on is a solution. It is only a short term work around while you fix your code. The solution is to correct any code that is dependent on register globals being on.

Link to comment
Share on other sites

<?php

session_start();

//$sess_id = session_id();

$username = $_SESSION['name'];

if(empty($username)){

header("location:index.php");}

 

$username = $_SESSION['username'];

 

 

 

 

$querystring = strstr($_SERVER['QUERY_STRING'], '&');

 

// Updating routines

 

 

$database = $_SESSION['database'];

$includepath = $_SESSION['includepath'];

$remotepath = $_SESSION['remotepath'];

$querystring = strstr($_SERVER['QUERY_STRING'], '&');

 

if (isset($_POST["id"]) && $_POST["Submit"] == "Update") {

 

$docid1 = $_POST['id'];

$doctitle = $_POST['need_name'];

      echo $docid1;

      echo $doctitle;

 

 

$updateSQL = "UPDATE cust_needs SET need_name = '$doctitle' WHERE id = $docid1";

 

//print $updateSQL;

//die;

 

$result = mysql_query($updateSQL) or die(mysql_error());

 

 

 

    header("Location: list_custneeds2.php?");

 

}

 

 

if (! empty($_GET["id"])) {

 

$docid = $_GET['id'];

$conn = mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD);

      //mysql_select_db(DB_NAME, $conn);

//dbconnect($database);

$selectSQL = "SELECT * FROM cust_needs WHERE id = $docid";

$result = mysql_query($selectSQL,$conn) or die(mysql_error());

$row = mysql_fetch_array($result);

 

}

?>

<html>

<head>

<title>Edit record</title>

<link href="Styles/admin.css" rel="stylesheet" type="text/css" />

</head>

<script language="javascript">

function redirect(){

    window.location = "archives.php?id=<?php print $_REQUEST[id];?>"

}

</script>

<body>

<?php include('_includes/top.inc'); ?>

<table border="0" align="center" cellpadding="10" cellspacing="0" bgcolor="#FFFFFF">

  <form action="docedit15.php" method="POST" name="formadd">

    <tr>

      <td style="border: 1px solid #AAAAAA"><table border="0" align="center" cellpadding="2" cellspacing="0">

          <tr>

            <td align="right" nowrap bgcolor="#DDDDDD">needid:</td>

            <td colspan="3" bgcolor="#DDDDDD"><input name="DocTitle" type="text" id="DocTitle" size="64" value="<?php echo $row['id']; ?>"/></td>

          </tr>

  <tr>

  <td align="right" nowrap bgcolor="#EFEFEF">needname:</td>

  <td colspan="3" bgcolor="#EFEFEF"><input name="SubTitle" type="text" id="SubTitle" size="64" value="<?php echo $row['need_name']; ?>"/></td>

  </tr>

 

         

 

<tr>

            <td bgcolor="#2D4A81" class="text10"><input type="button" value="« Back" title="Back to index page" onClick="javascript:history.go(-1)"></td>

            <td colspan="2" bgcolor="#2D4A81" class="text10"><input type="submit" name="Submit" value="Update" /></td>

            <td align="right" bgcolor="#2D4A81" class="text10"><input type="submit" name="Submit2" value="Delete" style="color:#FF0000" /></td>

          </tr>

        </table></td>

    </tr>

    <input type="hidden" name="id" value="<?php echo $docid; ?>">

<input type="hidden" name="querystring" value="<?php echo $querystring; ?>">

  </form>

</table>

</body>

</html>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.