Fengist's Recent Forum Activity

  • Browser.ExecJS("Date.now()") will give you the number of milliseconds between 1/1/1970 and now. You can put that number into local storage whenever you wish. When the user starts the game the next time, you can get that number again and subtract the stored value from the current value and know exactly how many milliseconds has elapsed since you stored that number.

    Browser.ExecJS("Date.now()") - stored value = milliseconds elapsed.

    One thing to take note of. Storing variables in local storage is not secure in any way. It's entirely possible, and not that difficult, for a user to go in and edit those variables manually.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Then he's not missing anything. What he wants is exactly what I described in the Delphi panels. If you drop a button on a panel in Delphi and you anchor the button to the bottom right of that panel, regardless of how that panel changes in size, the button will always maintain the same x and y position relative to the bottom right of the panel. Once the alignment of the panel and the anchoring of the components is set, you never have to screw with it again.

    There is nothing in Construct whereby I can layout objects and have them maintain their relative position to... well anything. Even pin has it's issues. I can't pin a button to the layout and have it stay in that spot. Instead, I'm forced to create a function that I have to call every time a layout starts or the browser resizes and I have to go through every single visible object on the layout and tell it exactly where I want it positioned and if I want it resized, relative to the viewport dimensions.

    For example. In the project I'm working on I have a sprite in the top right corner of the layout. I ALWAYS want it 10px from the top and 10px from the right, regardless of how the browser is sized. With a Delphi panel, I set it's anchors to top and right and place it... done. In Construct I have to tell it... no, no, I want you HERE... now DON'T MOVE.

  • Ok, I was just curious as to whether there might be characters in there that might affect the sql. Seems not.

    Well, I'm out of ideas. All I can tell you now is that the code is working. It's either your SQL that's not right or your database isn't right.

    • Post link icon

    Thanks for the update guys. As I've mentioned numerous times I'm a horrible JS hack so I'm rarely aware of the developments it undergoes. Nice to know you guys are already well into that ball-game. Google fed me that news this morning and I thot, humm... never heard of that before. Might be something new. Guess not. The way it sounds now, it was just a big publicity stunt for ebay.

    • Post link icon

    One of the biggest problems with web-based applications is speed. Languages like PHP are compiled by the server each time they're called (yes, the compiled bytecode is cached for speed). JS is compiled by the browser on the end user's computer each time they're called (which I assume is also cached).

    But imagine if you could compile your Construct app into an executable with assembly-like speed.

    https://www.techrepublic.com/article/replacing-javascript-with-webassembly-how-ebay-made-a-web-app-50x-faster-by-switching-programming-languages/

    This may be a long way off yet but...

  • What's the exact user name you're looking for?

  • Over the years I've worked with a lot of IDE's. One of the best is Delphi. It's called a RAD (Rapid Application Development) platform. One of the ways it makes things really easy to work with is something called panels. You can drop these panels on a form (layout) and give them various alignments, like top, left, bottom, center or even custom alignments. When you drop components (objects) onto them, they have anchors and they anchor themselves to the panels. You can set the anchors to any combination of top, bottom, left or right. The beauty of this is, as the form gets resized, the panels automatically resize based on their alignment and the components anchored to them stay in a position relative to their anchor setting. A top alignment will adjust it's width but not it's height, to match the form size. Left aligns, adjust height, but not width. Panels and anchors are an almost fool-proof way of developing aps and having all of the components stay exactly where you want them, regardless of the size of the form.

    That... is something I desperately miss in C3. Call them containers or what you wish, C3's methods for layout placement always forces me to manually place things exactly where I want them in the onStart and browser resize events. And to me, that's pretty clunky.

  • As for price there's two ways to do it.

    1. You make a FANTASTIC plugin that saves users TONS of time or gives them features they can't get anywhere else and charge a lot for it or.

    2. Bubblegum. You make a lot of simple plugins that make life easy and charge a little for each one.

  • It depends. Can the buttons be fully customized with CSS? Can the tooltips be customized with CSS? Can I change the fill and colors of the checkboxes and radio buttons? Are there onHover events and can I change the CSS when the hover event fires?

    Basically, as someone experienced in HTML and CSS can I make them look exactly the way I want, when I want but still make them look good when I don't want to mess with CSS?

    Can you make both noobs and pro's happy?

  • the error now returns:

    No user found with that name.

    That's perfect!

    That means that the username you searched for wasn't in the database. That's good because it means there were no errors. You connected to the database, you performed a query but it returned 0 results.

    Now, all you have to do is add a user to the database and search for them.

    Binding params is relatively new to php. It's purpose is to prevent things like SQL injection when getting query strings like $_GET. Basically, the way it works is this.

    In your query you substitute the ? for the insecure variables you want to put in the query.

    You then prepare the query. Then you bind the variables to the query. In the bind_param the 's' simply tells the bind command that you're passing a string and it substitutes the first ? (which it now knows is a string) for the $_GET["name"]. If you have say 3 ?'s in your query:

    SELECT id from user where username = ? and birthday = ? and country = ?

    $stmt->bind_param("sss", $_GET["username"], $_GET["birthday"], $_GET["country"])

    Then, you execute the query and finally get the results.

    Very glad you got it working!

  • Ok, I'm wholly unfamiliar with PDO and how it connects but the error you're getting is because it's failing to make a connection to the database so we need to do some error checking. I'm making a guess that you're using MySQL so let's try establishing a mysql connection instead:

    You currently have the PDO password set to '' which means, you aren't using one. I have yet to see an install of MySQL that allows no password on the root account unless you specifically set it to none.

    In the script below, you're going to need to replace DB_PASSWORD with the password you used when you set up the root account and put it inside single quotes like this:

    'password'

    If you're sure you don't have a password for that database then replace DB_PASSWORD with:

    ''

    Hopefully, this will work. Just run this from the browser. Once it does work, you can add in the:

    header('Access-Control-Allow-Origin: *');

    Back at the top.

    Take note, this produces a string as the AJAX result. From what I saw you had the result set to a number. If this does work, you will need to change it to see the errors.

    <?php
    $base = new mysqli('localhost', 'root', DB_PASSWORD, 'stockage');
    // Check connection
    if ($base->connect_errno) {
     die("Failed to connect to MySQL: " . $base->connect_error);
    }
    
    $sql = "SELECT id FROM user where username = ?";
    
    if (!$stmt = $base->prepare($sql))
    {
     echo "Prepare failed: (" . $stmt->errno . ") " . $stmt->error;
    }
    if (!$stmt->bind_param("s", $_GET['name'])){
     echo "Bind failed: (" . $stmt->errno . ") " . $stmt->error; 
    }
    if (!$stmt->execute()){
     echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error; 
    }
    if (!$result = $stmt->get_result()) {
     echo "Get result failed: (" . $stmt->errno . ") " . $stmt->error; 
    }
    if ($result->num_rows > 0) { 
     $row = $result->fetch_object();
     echo $row->id;
    }
    else
    {
     echo 'No user found with that name';
    }
    ?>
    
  • Because now you changed $base to $bdd

    <?php
    
    try
    {
     $base = new PDO('mysql:host=localhost;dbname=stockage;charset=utf8', 'root', '');
    }
    catch (Exception $e)
    {
     die('Erreur : ' . $e->getMessage());
    }
    	$sql = "SELECT id FROM user where username = ?";
    	$stmt = $base->prepare($sql);
    	$stmt->bind_param("s", $_GET['name']);
    	$stmt->execute();
    	$result = $stmt->get_result();
    	$row = $result->fetch_object();
    	echo $row->id;
    
    ?>

    Assuming you have a table named user with a field username and a field id (and those are case sensitive) this should work.

    login.php?name=theusername should give you the ID

    Once it works, but this back at the top:

    header('Access-Control-Allow-Origin: *');

Fengist's avatar

Fengist

Member since 6 Nov, 2015

Twitter
Fengist has 7 followers

Trophy Case

  • 10-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • x3
    Coach One of your tutorials has over 1,000 readers
  • x2
    Educator One of your tutorials has over 10,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

17/44
How to earn trophies