Jump to content

my stupidity solved


mendoz

Recommended Posts

Heyyyyy

I'm just trying to update a single column in a single row but cannot...

The table is 'site' and the column is 'scroll':
if it's set to 'yes' then enter 'no, and vice versa

[code]<?php
// Connect to the database
include("sql/conn.php");

// Select the databse
mysql_select_db($db_name) or die( "Unable to select database");

// This will get the value from the database
$query="SELECT scroll FROM site";
$scrollresult=mysql_query($query);
$scroll=mysql_result($scrollresult,0,"scroll");
echo "currently set to $scroll<br/><br/>";

if ($scroll=="yes") {
$newscroll="no";
} else {
$newscroll="yes";
}
echo "now it's set to $newscroll<br/><br/>";

// here is where it dies
$sql="update pc set scroll='$newscroll'"; // pc is the table and scroll is the column, there's only one row
$result=mysql_query($sql,$connection) or die(mysql_error());

?>[/code]

returns:

currently set to no

now it's set to yes

Unknown column 'scroll' in 'field list'
Link to comment
https://forums.phpfreaks.com/topic/30752-my-stupidity-solved/
Share on other sites

you had pc... should be site
[code]
<?php
include("sql/conn.php");
mysql_select_db($db_name) or die( "Unable to select database");

$scrollresult=mysql_query("SELECT scroll FROM site");
$scroll=mysql_result($scrollresult,0,"scroll");
echo "currently set to $scroll<br/><br/>";

if($scroll=="yes") $newscroll="no";
else $newscroll="yes";

echo "now it's set to $newscroll<br/><br/>";

// here is where it dies
$result=mysql_query("update site set `scroll`='$newscroll'") or die(mysql_error());
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/30752-my-stupidity-solved/#findComment-141738
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.