Jump to content

[SOLVED] Flippin' PHP errors!!


adamjones

Recommended Posts

Ok.

 

So on my CMS, I have tips that popup. Basically, when a user closes a tip, they are sent to 'turntip1off.php', and it should set 'tips' in the database to 'off', but I am getting an error.

 

This is a snippet from my CMS, where the tips appear;

 

<?php
$host="localhost";
$username="wowdream_domaine";
$password="password";
$db_name="wowdream_domaine";
$tbl_name="members";

mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);

while($rows=mysql_fetch_array($result)){
    if ($rows['tips1'] == on) {
        echo "<p id='tip' class='alert'>
		<span class='txt'><span class='icon'></span><strong>Tip:</strong> You should always 'Sign Out' before leaving the Admin Panel.</span>
		<a href='turntip1off.php'><span class='bg'></span>Close</a>
	</p>";
    } else {
        echo "";
    }
}
?>

 

And this is the 'turntip1off.php' code;

<?php
$host="localhost"; 
$username="wowdream_domaine";
$password="password";
$db_name="wowdream_domaine"; 
$tbl_name="members";

mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$sql="UPDATE `$tbl_name` WHERE username='$myusername' and password='$mypassword' SET `tips1`='off' WHERE `tips1`='on'";
$result=mysql_query($sql);

if($result){
header("location:admin.php");
}

else {
echo "ERROR";
}

?>

Link to comment
Share on other sites

Why dont you try in turntrip1off.

 

<?php
$host="localhost"; 
$username="wowdream_domaine";
$password="password";
$db_name="wowdream_domaine"; 
$tbl_name="members";

mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$sql= "UPDATE $tbl_name SET tips1 =  'off'  WHERE username='$myusername' AND password= '$mypassword'";
$result=mysql_query($sql);

if($result){
header("location:admin.php");
}

else {
echo "ERROR";
}

?>

Link to comment
Share on other sites

Parse error: syntax error, unexpected '}', expecting ',' or ';' in /home/wowdream/public_html/domaine/admin/beta/turntip1off.php on line 20

 

You weren't supposed to put the damn quotes. =/  Just change that whole line to:

mysql_error();

 

Remove the echo and everything.

Link to comment
Share on other sites

Once you get the code modified so that the mysql_error() statement will tell you why the query failed, it will report an sql syntax error.

 

This is the syntax prototype of an UPDATE query (taken from the mysql manual) -

UPDATE [LOW_PRIORITY] [iGNORE] tbl_name

    SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ...

    [WHERE where_condition]

    [ORDER BY ...]

    [LIMIT row_count]

 

The items are shown in the order they need to appear in to make a valid statement. []'s enclose optional items, but when they are present, they must be in the order shown in the syntax prototype.

 

For your query -

 

UPDATE tbl_name

    SET col_name1=expr1

    WHERE where_condition

 

Link to comment
Share on other sites

Lets get it to show your error change your turntip1off to this

<?php
$host="localhost"; 
$username="wowdream_domaine";
$password="password";
$db_name="wowdream_domaine"; 
$tbl_name="members";

mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$query  = "UPDATE $tbl_name SET tips1='off' WHERE username= '$myusername' AND password='$mypassword'";
  mysql_query($query) or die('Error, insert query failed: '.mysql_error());
  header("Location: admin.php");

?>

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.