Jump to content

iRoot121

Members
  • Posts

    36
  • Joined

  • Last visited

Posts posted by iRoot121

  1. Hi guys,

     

    I wanted to make a script login to the website Marktplaats.nl, but it doesn't seem to work..

    At the moment I can't post the code as it's on my laptop.

     

    Does anyone know how to login and maybe do other stuff on Marktplaats.nl with cURL?

     

    Kind regards,

    Kevin Ruhl.

  2. Hi,

     

    I'm trying to make a program that filters data out of a website. Now I've got a problem.

    For example, I've this line:

    <td class="maintxt" width="200"><a href="profile.php?x=Stranger">Stranger</a></td><td class="maintxt" width="200">Godfather (96.76%)</td><td class="maintxt" width="200"><i><a href="clanprofile.php?x=Ettertjes">Ettertjes</a></i></td>
    

    Form this line I want to set the word "Stranger" in a variable, and do the same for the word "Godfather". What is the best method to do this?

     

    Thanks in advance,

    iRoot121

  3. Hi, I'm trying to let JavaScript check if a givin user exist in the database.

     

    It seems that the _check-user.php always returns 0, but if I fill in a name that doesn't exist, and echo out the result variable in JS, the echo will return 1.

     

    Is there someone who could help me?

     

    JavaScript part:

    function checkUser() {
    	$.post("_check_user.php", { 'username': document.getElementById("username").value }, function(result) {
    		if (result == 1) {
    			document.getElementById("checkUser").className = "succes";
    			document.getElementById("checkUser").innerHTML = "Name is available";
    		}else{
    			document.getElementById("checkUser").className = "errormsg";
    			document.getElementById("checkUser").innerHTML = "Name is not available!";
    		}
    	});
    }
    

    _check-user.php:

    <?php
    include("config.php");
    
    $result = mysql_query("SELECT login FROM users WHERE login='".clean_string($_POST["username"])."'");
    
    if(mysql_num_rows($result)>0){
    	echo 0;
    }else{
    	echo 1;
    }
    
    ?>
    
  4. here's a possibility, you are running that code a second time with an empty $_POST["bet"] value (or you have some other update code later in the program) and are updating the values back to the original values in $info["cash"] and $object["bank"]?

     

    at this point (i.e. a page that's doing something unexplained), seeing all the code needed to reproduce the problem would lead to the quickest solution.

    Yea, that could be possible. Here is the code if you want to take a look at it: http://pastebin.com/JDWZuf2b

    The update query is on line 431

  5. Can you post all that code so we can see it too?

    Do you mean the whole page? If so, do you want to have a pastebin, or should I just paste it here?

     

    EDIT: Here is the code for the error handling:

    $q = "UPDATE users SET cash='".clean_string($info["cash"]-$_POST["bet"])."' WHERE login='".$info["login"]."'";
    echo "Query is <br>$q";
    $qresults = MySQL_query($q);
    if (!$qresults)
    {
    	echo "Error in query - msg is<br>" . MySQL_error();
    	exit();
    }
    $q2 = "UPDATE objecten SET bank='".clean_string($object["bank"]+$_POST["bet"])."' WHERE type='4' AND land='".$info["land"]."'";
    echo "Query is <br>$q2";
    $qresults2 = MySQL_query($q2);
    if (!$qresults2)
    {
    	echo "Error in query - msg is<br>" . MySQL_error();
    	exit();
    }
    
    
  6. Numeric fields usually don't need quotes on the values.  That may cause the query to not be running.

     

    Try this syntax:

    $q = "update........ where.......";
    echo "Query is <br>$q";
    $qresults = MySQL_query($q);
    if (!$qresults)
    {
        echo "Error in query - msg is<br>" . MySQL_error();
        exit();
    }
    

    By assigning the query result to a variable you can check the success/failure of the query.

     

    By assigning the query statement to a variable you can positively be sure that you are echoing the exact query statement.

    If I use that for both queries, I get:

    Query is
    UPDATE users SET cash='13000' WHERE login='Goed'
    
    Query is
    UPDATE objecten SET bank='9223372036854774807' WHERE type='4' AND land='1'
    

    as output, no errors or whatever.

  7. you likely have some white-space/non-printing characters as part of the data. what does using var_dump() on each of the php variables - $info["cash"], $_POST["bet"], $info["login"], $object["bank"], and $info["land"] show (this is primary looking for the length to see if it matches the number of printing characters being displayed)?

     

    If I echo the var_dumps like this:

    echo '$info["login"]: '.var_dump($info["login"]);
    echo '$_POST["bet"]: '.var_dump($_POST["bet"]);
    echo '$info["cash"]: '.var_dump($info["cash"]);
    echo '$info["land"]: '.var_dump($info["land"]);
    

    I get string(4) "Goed" $info["login"]: string(4) "1000" $_POST["bet"]: string(5) "14000" $info["cash"]: string(1) "1" $info["land"]: as output. Do you need any more information?

  8. your WHERE clause is likely false or the value being updated isn't valid for the field type.

     

    which of those queries isn't working and it would be helpful if you posted the query that you echoed so that we could see it to see if there is anything obvious about it that could be causing the problem.

    Both of the queries aren't working. And if I do:

    echo "UPDATE users SET cash='".clean_string($info["cash"]-$_POST["bet"])."' WHERE login='".$info["login"]."'";
    echo "UPDATE objecten SET bank='".clean_string($object["bank"]+$_POST["bet"])."' WHERE type='4' AND land='".$info["land"]."'";
    

    I get UPDATE users SET cash='12000' WHERE login='Goed' AND UPDATE objecten SET bank='775807' WHERE type='4' AND land='1' as output, so the variables are set.

     

    By the way, if I throw these outputs in PHPMyAdmin, the query works perfectly.

  9. Hi,

     

    When I run an UPDATE query in my PHP code, nothing happends, no errors or anything. The weardest thing is, is that if I echo the query, it's the correct output. Any other queries that come after them are still executed.

     

    This is my query code:

    mysql_query("UPDATE users SET cash='".clean_string($info["cash"]-$_POST["bet"])."' WHERE login='".$info["login"]."'") or die(mysql_error());
    mysql_query("UPDATE objecten SET bank='".clean_string($object["bank"]+$_POST["bet"])."' WHERE type='4' AND land='".$info["land"]."'") or die(mysql_error());
    

    Thanks in advance,

    iRoot121.

  10. Hi guys, I had a question about how to do a safe query.

     

    For example, I've a query like SELECT * FROM users WHERE login='".$_GET["x"]."'

    Do I need to do more then just adding mysql_real_escape_string(), or is that one just enough?

     

    And how goes it for the INSERT, UPDATE, DELETE statement?

     

    And do you need to parse the output from a database before displaying it?

     

    Thanks in advance,

  11. I asume you want to have some sort of userlist, with a link to each user's profile.

     

    So, if this is the case, you can do something like this:

     

    Members.php:

    <?php
    $sql = mysql_query("SELECT * FROM `users` ORDER BY `id`");
    if ($sql) {
        while ($info = mysql_fetch_array($sql)) {
            //Some userinfo here.
            //The link to the user his profile.
            echo '<a href="profile.php?user='.$info["id"].'">More info about this user.</a>';
        }
    }else{
        die(mysql_error());
    }
    ?>
    

    Profile.php:

    if (!isset($_GET['user']) || $_GET['user'] == "") {
        echo 'Please insert a user to lookup..';
        exit;
    }else{
        $sql = mysql_query("SELECT * FROM users WHERE id='".$_GET['user']."'");
        if (mysql_num_rows($sql)>0) {
    	while ($info= mysql_fetch_array($sql)) {
                //User information to display.
            }
        }else{
            echo 'This user isn\'t in our database!';
            exit;
        }
    }
    
  12. Hai guys,

     

    I'm programming something like a text-based game now, but I've a question..

     

    I want to have a script running, that updates every hour (01:00, 02:00, etc.) the values of some MySQL tables.

     

    I've now something like this, but I don't know if this is the right way to do it. So do you guys have any tips to do something like this? Thanks in advance.

     

    Updater.php:

    if (date("i", time()) == "00") {
    	while($x = mysql_fetch_object($dbres))
    	$update[$x->name]		= $x->time;
    	
    	if(floor($update['hour']/3600) != floor(time()/3600)) {
    		$dbres				= mysql_query("SELECT GET_LOCK('hour_update',0)");
    		if(mysql_result($dbres,0) == 1) {
    			$cron_pass			= "secretcronpassword";
    			mysql_query("UPDATE `cron` SET `time`='".time()."' WHERE `name`='hour'");
    			include("_cron_hour.php");
    			mysql_query("SELECT RELEASE_LOCK('hour_update')");
    		}
    	}
    }
    

    _cron_hour.php:

    if($cron_pass != "secretcronpassword")
        exit;
    
    $dbres = mysql_query("SELECT * FROM `aandelen`");
    while($aandeel = mysql_fetch_object($dbres)) {
    	$koersmin      = rand(1,500);
    	$koersplus       = rand(1,500);
    
    	mysql_query("UPDATE `aandelen` SET `koers`=`koers`+$koersplus WHERE `naam`='".$aandeel["naam"]."'");
    	mysql_query("UPDATE `aandelen` SET `koers`=`koers`-$koersmin WHERE `naam`='".$aandeel["naam"]."'");
    }
    
    if($aandeel["koers"] < 2500) {
    	mysql_query("UPDATE `aandelen` SET `koers`=10000 WHERE `naam`='".$aandeel["naam"]."'");
    }
    
    $sql1 = mysql_query("SELECT * FROM users WHERE uurloon='1' AND familie <> 'Geen'");
    if (mysql_num_rows($sql1)>0) {
        while($info2 = mysql_fetch_array($sql1)) {
    		$row = mysql_fetch_assoc(mysql_query("SELECT * FROM families WHERE name='".$info2["familie"]."'"));
            mysql_query("UPDATE users SET cash='".($info2["cash"]+((($row["aandelen"]*200)/100)*25))."', bank='".($info2["bank"]+((($row["aandelen"]*200)/100)*75))."' WHERE login='".$info2["login"]."'");
        }
    }
    
  13. Hai guys, I'm busy with a category display script, but do I replace the text for an URL?

     

    Example:

    I've this code at the moment:

    <?php
    $query="SELECT `cat` FROM `video` WHERE `id`='".$_GET['video']."'";
    $sql=mysql_query($query) or die(mysql_error());
    while($line=mysql_fetch_array($sql))
    {
        echo ''.$line['cat'].'';
    }
    ?>
    

    The output for example is: Category1,Category2,Category3.

     

    So, what do I need to let the output be like this: <a href="category.php?cat=Category1">Category1</a>, <a href="category.php?cat=Category2">Category2</a>, <a href="category.php?cat=Category3">Category3</a>

     

    Thanks for any help! :)

  14. $id = $_POST["id"];
    				$sql=mysql_query("SELECT `title`,`url`,`volg`, `headerpicture`, `picture`, `product_id` FROM `pagina` WHERE `id`='".$id."' LIMIT 0,1");
    				$row=mysql_fetch_assoc($sql); 

    Should be this xD: 

    $id = $_POST["id"];
    				$sql=mysql_query("SELECT `title`,`url`,`volg`, `headerpicture`, `picture`, `product_id` FROM `pagina` WHERE `id`='".$id."' LIMIT 0,1");
    				$row_pagina=mysql_fetch_assoc($sql);
                                    $product_id2 = $row_pagina['product_id'];
    				
    				$sql2=mysql_query("SELECT * FROM `producten` WHERE `id`='".$product_id2."' LIMIT 0,1");
    				$row=mysql_fetch_assoc($sql2);
    
  15. Hi all, I've a problem with my PHP code.

     

    I've a page, where you can select multiple pages, which will be displayed at the related section on my site.

    So far, you can select the pages, and they will be injected into the database, and they will be displayed on the site.

    My only problem is: the pages won't be selected on the edit page.

    I've this piece of code, and I don't know what I'm doing wrong.

    <?php
    				$id = $_POST["id"];
    				$sql=mysql_query("SELECT `title`,`url`,`volg`, `headerpicture`, `picture`, `product_id` FROM `pagina` WHERE `id`='".$id."' LIMIT 0,1");
    				$row=mysql_fetch_assoc($sql);
    				echo '<select MULTIPLE name="related[]">';
    				if ($row['related'] != '')
    				$related_array=explode(',',$row['related']);
    				else
    				$related_array=array();
    				$query="SELECT `id` FROM `producten`";
    				$sql=mysql_query($query) or die(mysql_error());
    				while($line=mysql_fetch_array($sql))
    				{
    					$query1="SELECT `title` FROM `pagina` WHERE `product`=1 AND `product_id`='".$line['id']."'";
    					$sql1=mysql_query($query1);
    					if(mysql_num_rows($sql1) >0)
    					{
    						$line1=mysql_fetch_array($sql1);
    						$selected=' ';
    						foreach($related_array as $related_line)
    						{
    							if ($related_line == $line['id'])
    							$selected=' selected ';
    						}
    						echo '<option'.$selected.'value="'.$line['id'].'">'.$line1['title'].'</option>';
    					}
    				}
    				echo '</select>';
    				?>
    

    What am I doing wrong? Is there a piece of code I need to script?

  16. Can you post the exact values of your variables in the query?

    It's not much :P.

    $title = Test2;
    $korting = 0;
    $volg = 0;
    $product = 1;
    $visible = 1;
    $metadescription = Test2;
    $url = test2;
    $content = Test2;
    $id = 1708;
    

    I've also tried this:

    $title = Test3;
    $id = 1708;
    

    And with both he's updating now. So I'm going to try it with a select statement.

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