Jump to content

can i get hand please


Jiraiya

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());

 

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.