Jump to content

Recommended Posts

i have my script thats supposed to edit one variable if only if another variable is equal to or greater then 5 million but it dosnt seem to work here is the script

 

<?php

mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("members") or die(mysql_error());


$sql = mysql_query("SELECT * FROM users WHERE username = '$username'");
$row = mysql_fetch_array($sql);
if($row['skill'] > 5000000){
mysql_query("UPDATE `users` SET `village` = 'Akatsuki' WHERE username = '$username'") or die(mysql_error());
}
?>


Link to comment
https://forums.phpfreaks.com/topic/137234-can-i-get-hand-please/
Share on other sites

is that right?


$username = $_COOKIE['ID_my_site'];

$sql = mysql_query("SELECT * FROM users WHERE username = '$username'");
$row = mysql_fetch_array($sql);
if($row['skill'] > 5000000){
mysql_query("UPDATE `users` SET `village` = 'Akatsuki' WHERE username = '$username'") or die(mysql_error());
}
?>

Where do you get $username from?

You can just update it in 1 query.

 

$sql = "UPDATE `users` SET `village` = 'Akatsuki' WHERE username = '$username' AND skill > 5000000";
mysql_query($sql) or die(mysql_error());

 

This is how you should do it, instead of 2 querys as stated.

 

<?php
if (isset($_COOKIE['ID_my_site'])) {
     $username = $_COOKIE['ID_my_site']; 
     $sql = "UPDATE `users` SET `village` = 'Akatsuki' WHERE username = '$username' AND skill > 5000000";
     mysql_query($sql) or die(mysql_error());
}

 

As long as there is a username in the cookie that should work. (I would store the username in session as appose to a cookie but yea.)

Sounds like you have it in the wrong place, should be after your $sql variable

 

$sql = "UPDATE `users` SET `village` = 'Akatsuki' WHERE username = '$username' AND skill > 5000000";

 

echo "query: " . $sql . "<br />username: " . $username;

 

mysql_query($sql) or die(mysql_error());

 

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.