Jump to content

DaveyK

Members
  • Posts

    289
  • Joined

  • Last visited

  • Days Won

    1

DaveyK last won the day on June 24 2013

DaveyK had the most liked content!

About DaveyK

  • Birthday June 9

Profile Information

  • Gender
    Male
  • Location
    The Netherlands

DaveyK's Achievements

Newbie

Newbie (1/5)

9

Reputation

  1. $sql = "SELECT * FROM tbl_Users WHERE Email='$Email'"; $result = mysqli_query($conn, $sql); the $result value in this case is the mysqli object, but as mac_gyver previously mentioned: it is not the actual result of the query. You will still need another mysqli_fetch_* function to retrieve the data. Since all you need the above function to perform is return a count, you can implement that in the SQL itself, which is far more efficient. You should look into editing your query to implement a COUNT, as well as adding a mysqli_fetch_* function to return said count. Which mysqli_fetch_ function you should use, you can lookup in the documentation. A good practise would be to make sure the returned COUNT works before trying to insert anything into the database. It makes debugging a lot easier.
  2. God I used to be so good at this stuff, but I totally forgot about it. I remember the asymptote stuff, which is what I would like to achieve to limit the minimum time. The minimum amount of "resource" is something I just need to set in the php. This is the lineair plot: http://wolfr.am/1ax2KGH This looks more like the curve I would like to have in the end, though the equation itself isnt good: http://wolfr.am/1ax2XcL As you can see in the second example, the actual impact it now has on the time is super small, but the curve itself looks better (even though I am not sure this has an asymptote).
  3. Also I know I can code a minimum using a min() or max() function, I would just like to do it inside of the equation...
  4. I implemented the function you gave me, but I noticed that it would ALWAYS make the time shorter even if you decide to spend less money than the base amount of money. That is not very realistic. I went with: $quality = 100; $base_time = 60; $coin_factor = 0.16; $base_coin = 100; $actual_coin = 200; $t = round($base_time * (1 - ($coin_factor * (($actual_coin - $base_coin) / $base_coin))) * ($quality / 100), 3); At this point I do not know if Im entirely happy with the way that decreases the actual time. For now it works though. HOWEVER, I am facing a rather different issue. This makes it linear, and I would like the function to be a curve, however I really dont remember how to do that... It shouldnt be very steep and it shouldnt ever be able to go under 30% of the base time. This is probably going to be a really long function, considering I am planning on not just using coin as a "resource" but maybe some other things as well. I have no idea how I should manage that at this point.
  5. Most likely your issue is either a faulty name in your input tag or the wrong method in your form
  6. Perfect, that's exactly the leg up i needed. I'll be back with some php soon
  7. Hey guys, Ive been tossing around the idea of creating one of my own games. I know its been done over and over again, but its more something for me personally. Anyway, I dislike the idea that a lot of games have static "cost" and "time" aspects. In real life, would you considering building something, the "cost" greatly influences the "time" and the "quality" of said building. Basically, I know pretty much that 3 variables is really hard. So for starters, I would set quality to 100%. So what I would like to do, is write a script where I could say something like this: Quality: 100% Normal building time: 1h Normal cost: 100 coins But if you spend 200 coins, the building time is decreased by a factor (say 0.08 for every increase), so say you spend: 200 coins -> (200/100)= 2 ; 2 * 0.08 = 0.16, which means you roughly save 10mins. (building time 50 minutes). It basically works like this image:http://www.the-self-build-guide.co.uk/image-files/time-cost-quality-triangle.jpg Regardless, do you have any tips how I should code this? I know the math behind it but the automation seems rather difficult... also, this should work both ways, so if I were to say I wanted the building time to be 30mins, I would have to know the respective building cost as well. And its not likely building cost are just going to be money (coins), but other "resources" as well. I have a feeling this system is easy to abuse though and I am not entirely sure how I would code this at all.
  8. http://php.net/manual/en/pdostatement.bindvalue.php In the examples they also use the colons ':'. Try that.
  9. $query = mysql_query("SELECT * FROM rodocontent ORDER BY 'efternamn' ASC"); returns false, try: $query = mysql_query("SELECT * FROM rodocontent ORDER BY 'efternamn' ASC") or die(mysql_error()); ALSO, there are like a THOUSAND records on this issue on google. Do your own research please.
  10. Its basic form handling. Basically you have something like: <?php if (isset($_POST['submit'])) { if ($_POST['text'] = 'xyz') { // do something } } ?> <form action="/file.php" method="post"> <input type="text" name="text" /> <input type="submit" name="submit" value="Submit" /> </form>
  11. Please read: http://php.net/manual/en/function.mysql-connect.php and try to understand what the function does. The fourth parameter you are passing, which you think is the table, is in fact: new_link If a second call is made to mysql_connect() with the same arguments, no new link will be established, but instead, the link identifier of the already opened link will be returned. The new_link parameter modifies this behavior and makes mysql_connect() always open a new link, even if mysql_connect() was called before with the same parameters. In SQL safe mode, this parameter is ignored. This is also from the same PHP.net page. You probably got confused with mysqli_connect() but they are very different So, now you must be wondering: how in the bloody world can I select a database in mysql? ----> http://bit.ly/19t20Ib
  12. or crypt(), works just fine. Actually on topic though, as mac gyver said your login logic (hashing) should be EXACTLY the same hashing you use for registering. This: This time when I register a new user, which works fine, then I attempt to login into that user on the webpage, it doesn't go through, but if I go into my database and copy the column with the password that's been encrypted and paste it into the password field on the webpage, it works. makes me believe your login logic isnt hashing at all.
  13. What makes you think mysql_close() would close the connection? /sarcasm. Ofcourse it closes the connection! Also Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/curem8019/public_html/connect.php on line 20 is not an error on line 20, its an error on the line which holds the mysql query. The query itself is making the mysql_query() function return false. There is an error in your query. What you need to start doing is post code in code tags: <?php $link = mysql_connect('localhost', 'curem5801_pogopat', 'chickenkievs427','curem8019_languages'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; $sql = "SELECT * FROM `Rebus_tbl`"; $query = mysql_query( $sql ); echo "<table>"; //now read and display the entire row of a table one by one looping through it. //to loop we are using While condition here while( $row = mysql_fetch_assoc($query) ) { echo "<tr><td>$row[Word]</td></tr>"; echo "<tr><td>$row[Order]</td></tr>"; echo "<tr><td>$row[Translation]</td></tr>"; } echo "</table>"; ?> like that. The error is, as I said cause by: $query = mysql_query( $sql ); what you need to do is: $query = mysql_query( $sql ) or die(mysql_error()); That will echo an error.
  14. What have you tried so far? We are not here to do your stuff for you. Use Google.
  15. all the warnings you posted are Warning: mysql_query() [function.mysql-query]: Access denied for user 'curem801'@'localhost' (using password: NO) in /home/curem801/public_html/connect.php on line 12 function.mysql-query Appereantly you are not able to connect to the DB.
×
×
  • 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.