Jump to content

iRoot121

Members
  • Posts

    36
  • Joined

  • Last visited

Everything 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. I've already got the solution: after the UPDATE query there was another query that said: update the cash of the user with the cash + an amount of cash. But the second query had the old cash value, not the updated one. Thanks for helping anyway guys!
  5. 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
  6. 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(); }
  7. 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.
  8. 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?
  9. 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.
  10. 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.
  11. Hi guys, I was wondering, is it possible to split an array into pages with 10 values on each page? And how can I make a navigation bar with Page 1 2 3 in it? And if it's possible, how would I do that? Thanks in advance, iRoot121
  12. 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,
  13. Thanks for the info, I'll change the MySQL values .
  14. 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; } }
  15. I don't think there is one. Except that the table needs to be sorted again after a cache clean.
  16. 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"]."'"); } }
  17. Thanks cyberRobot and Ch0cu3r! It's working fine now!
  18. Well, that doesn't work . Because the there's just one output in the while, and that is 'Category1,Category2,Category3'. So, is there any way to explode every word after the ','?
  19. 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!
  20. $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);
  21. 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?
  22. Thanks, but I found the problem I think.. If I place a second connection to the database, above the $query_update script, then it works. (gonna look later why that's needed o.O) Thanks for helping me alot! And jazzman1, I'll watch the videos .
  23. It's not much . $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.