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