Re: php 4.0.5 to php 4.2.2
| From: | Chris Mach | Date: | Tue, 22 Apr 2003 19:23:51 +0000 |
| Subject: | Re: php 4.0.5 to php 4.2.2 | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-27273@lists.php.net to get a copy of this message | ||
It's not my server so I don't think i have access to change the php.ini
file.
I tried the $_POST["title"] and $HTTP_POST_VARS["title"] and it worked,
except now it replaces my previous data instead of adding a new record.
Is there a way that i can use $_POST in combination with my array variable
$myrow?
http://matrix.senecac.on.ca/~cjmach/test.php
<html>
<body>
<?php
$host="www.freesql.org";
$user="cm6";
$password="pizzasub";
//Connect and select the database for use
$db = mysql_connect($host,$user,$password) or die("Could not connect: " .
mysql_error());
mysql_select_db("55yardline",$db);
$result = mysql_query("SELECT * FROM news WHERE id < 50",$db);
if ($myrow = mysql_fetch_array($result)) {
echo "<table border=0 width=600 align=center>\n";
echo "<tr><td>News</td></tr>\n";
do
{
printf("<tr><td><b>%s</b></td></tr><tr><td>%s<br><br><br><br></td></tr>\n",
$HTTP_POST_VARS["title"], $HTTP_POST_VARS["copy"]);
}
while ($myrow = mysql_fetch_array($result));
echo "</table>\n";
}
else
{
echo "Sorry, no records were found!";
}
if ($submit) {
$sql = "INSERT INTO news (title,copy) VALUES
('title','shit')";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";
} else{
?>
<form method="post" action="<?php echo $PHP_SELF?>">
Enter Title:<br><input type="text"
name="title"><br>
Enter Copy:<br><textarea name="copy" cols="75"
rows="10"></textarea><br>
<input type="Submit" name="submit" value="Enter
information">
</form>
<?php
}
?>
</body>
</html>
"Peter Lovatt" <pjln1@sunmaia.net> wrote in message
news:NFBBKAGAILLHPFOOAKFIOEHBFOAA.pjln1@sunmaia.net...
> Is register_globals off in php.ini - if so, the variable $title won't
> register.
>
> Try $_POST["title"] or $HTTP_POST_VARS["title"]
>
> HTH
>
> Peter
>
> -----Original Message-----
> From: Chris Mach [mailto:cjmach@learn.senecac.on.ca]
> Sent: 22 April 2003 07:48
> To: php-db@lists.php.net
> Subject: [PHP-DB] php 4.0.5 to php 4.2.2
>
>
> I originally wrote some php scripts (php 4.0.5) which would update my
mysql
> database. Now i need to move to a different server (php 4.2.2) and now i
> can't get my INSERT query to work now. Is there something i don't know
about
> upgrading versions of php?
>
>
> <html>
> <body>
> <?php
>
> $host="www.freesql.org";
> $user="***";
> $password="********";
>
> //Connect and select the database for use
> $db = mysql_connect($host,$user,$password) or die("Could not connect: " .
> mysql_error());
> mysql_select_db("55yardline",$db);
>
> $result = mysql_query("SELECT * FROM news WHERE id < 50",$db);
>
> if ($myrow = mysql_fetch_array($result)) {
> echo "<table border=0 width=600 align=center>\n";
> echo "<tr><td>News</td></tr>\n";
> do
> {
>
>
printf("<tr><td><b>%s</b></td></tr><tr><td>%s<br><br><br><br></td></tr>\n",
> $myrow["title"], $myrow["copy"]);
> }
> while ($myrow = mysql_fetch_array($result));
> echo "</table>\n";
> }
> else
> {
> echo "Sorry, no records were found!";
>
> }
>
>
>
> if ($submit) {
> $sql = "INSERT INTO news (title,copy) VALUES
> ('$title','shit')";
> $result = mysql_query($sql);
> echo "Thank you! Information entered.\n";
> } else{
> ?>
>
> <form method="post" action="<?php echo
> $PHP_SELF?>">
> Enter Data:<textarea name="title" cols="75"
> rows="10"></textarea>
> <input type="Submit" name="submit" value="Enter
> information">
> </form>
>
> <?php
> }
> ?>
>
> </body>
> </html>
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>