Jump to content

kicken

Gurus
  • Content Count

    3,465
  • Joined

  • Last visited

  • Days Won

    86

Everything posted by kicken

  1. kicken

    Organizing related applications

    If you're developing them as essentially separate sites I'd probably give them separate repositories as well. I'd also use separate domains such as www.example.com and admin.example.com, which would then end up being separate folders on disk such as /var/www/www.example.com/ and /var/www/admin.example.com/ Whatever works best for you and makes sense is probably fine though. I'm currently working on an API for an existing site. Like you the API and the site share the same database but are separate things more or less. The API has it's own git repository and is stored on a separate folder on the server. Since I don't control to domain it'll end up just being a sub-folder of the current site via an Alias /api /var/www/example-api in the server configuration.
  2. kicken

    maybe I'm searching incorrectly?

    If you're data is getting duplicated then you're calling mysqli_query twice with your insert query. mysqli_insert_id doesn't cause duplication, it just returns the id generated by the previous insert query. Also, if you want to prevent duplicate email addresses you should have a UNIQUE constraint on that column, not query the table first.
  3. kicken

    403 surprise

    It sounds like you're host may have installed something like mod_security and your post data is getting caught as a possible sql injection attempt. You might be able to disable it. Otherwise, you may just have to re-structure your data to avoid it. I'm not really familiar with mod_security. Never used it or anything similar in my setups.
  4. kicken

    Sessions Problem?

    You're still using cookies, so what's wrong with just using the default setup? If you really don't want them to be named PHPSESID then just change the session.name value. Change your session.save_path to a secure folder dedicated to your application. There's nothing you need to do beyond that. Just use sessions in the normal fashion by calling session_start() and manipulating the $_SESSION variable.
  5. jQuery(document).ready(function(){ ... }); That code is run when the page is first loaded. At that point your form inputs do not exist so that's why it won't find them. Your updateStock function on the other hand is not run until the onclick event of your button. At that point the element does exist. The code you posted doesn't really make sense so it might be best to explain what your trying to accomplish. I'm guessing your goal is to respond to the buttons being clicked but by using some jQuery code rather than an inline onclick="" function. If that's the case then you'll want to attach a click handler to some part of the page that doesn't change and filter for the buttons. You can do that using the .on function. For example: //Wait til the page is loaded jQuery(function($){ //Attach a click handler to the #iddiv_searchresultsarea. Filter clicks to only those on a <button class="update-stock"> element. $('#iddiv_searchresultsarea').on('click', 'button.update-stock', function(){ //$button is the button that was clicked. var $button = $(this); }); }); On a side note, jQuery(document).ready(function(){ ... }); is the older method of running stuff when the page is ready. The newer and preferred method is like I show above.
  6. Yes, it appears to be.
  7. You shouldn't even need to assign it to a new mypn variable like that. your original code where you just used pn directly should work just fine.
  8. You're apparently trying to call mysqli_query with a query that has placeholders. You can't do that, if you want to use placeholders then you have to use mysqli_prepare then bind your parameters, then mysqli_stmt_execute.
  9. I'd go XML. Keep in mind that DocBlocks are just comments, and in theory one should be able to strip out comments without affecting how a script works. Doing mappings and other things inside the DocBlock is turning your comments into code that is essential for your script to operate. This can cause problems in some instances such as if you use an opcache that doesn't preserve comments.
  10. kicken

    Is there a proper way to set this up?

    I remember many year ago I had issues with $_SERVER['DOCUMENT_ROOT'] not existing on IIS+PHP setup. Can't remember the versions involved. I ended up using a define based on __FILE__ as a workaround (__DIR__ didn't exist then). Now day's I just use __DIR__ and .. as necessary, eg: define('PROJECT_ROOT', __DIR__.'/../../'); //or require __DIR__.'/../../config.inc.php';
  11. Depends I suppose on what your goal is. If you want to make use of existing RC stuff and all that stuff is geared to work with an RF based protocol then use that. If you want to use a smartphone / tablet / PC to control the car then WiFi would be a better fit as those devices are likely to already have a WiFi card. I've only dabbled in Arduino/hardware and done pretty much nothing with regards to RC/RF stuff so can't really say much more than the above.
  12. kicken

    Is there a proper way to set this up?

    Rather than absolute URL some people refer to these as domain relative URL's. Essentially when you begin the url with a / you are specifying the full path from the root domain name. If you want to link to localhost/mysite/index then you use <a href="/mysite/index">. If you want the /mysite part to be changeable (say if you had an app you could drop into any folder on the site) then the easiest thing to do is to simply make it a configuration option in the application, for example: config.php: define('APP_PREFIX', '/mysite'); header.php: <?php include('config.php'); ?> <link href="<?=APP_PREFIX?>/css/screen.css" media="screen" rel="stylesheet" /> <script src="<?=APP_REFIX?>/javascripts/jquery.js"></script>
  13. kicken

    Software recommendations for documentation

    Just use exec() to run the same command you'd run on the command line. exec('/usr/bin/php /usr/share/phar/phpDocumentor.phar -d myDir -t myTarget'); If you need your directory and target to be dynamic use variables and escape them properly.
  14. kicken

    Software recommendations for documentation

    Try using the phar file instead of through pear. Worked ok for me when I tried it.
  15. Websocket's require a lot of extra overhead for an arduino. You'd have to implement (or find a library for) a webserver with HTTP and websocket support. All that overhead is going to be eating up your available memory leaving less for your actual car controlling code to work with. A simple UDP setup would be best probably. Just fire off some data packets with commands for the car. With UDP there's a chance some may get lost in transit, if that's a problem then use TCP instead. Keep things simple.
  16. kicken

    Is there a proper way to set this up?

    @imgrooot, your example code doesn't show any need to generate an absolute URL, at least not dynamically. You'd just replace your URL's with absolute versions as demonstrated by requinix. The absolute URL's don't change based on the location of the script because you're always referencing from the root of the website rather than the current script's location. If you think you need to somehow dynamically generate an absolute URL then you'll need to expand on why you think that is and the details of your situation.
  17. kicken

    month/date with leading zero

    Your existing birthdate = code is not how you change a hidden input's value, all it does is assign a value to the variable birthdate. If you want to change a hidden input's value then you need to change the value attribute on that input element by assigning to it. Similar to when you read an input's value, but for writing instead. function date_to_database() { document.getElementById('birthdate').value = document.getElementById("year").value + "-" + document.getElementById("month").value + "-" + document.getElementById("date").value; alert("The dob to be passed is: " + document.getElementById('birthdate').value); } However, there's no real point in assembling things client side into a hidden field when you can just use PHP to assemble the date parts server-side when the form is submitted.
  18. kicken

    PDO double entries

    There is a UTF Byte order mark at the end of the code when I copy and paste it that causes an error. Not sure if that is in your original file or just an artifact of the copy/paste process. If you copied code from somewhere into visual studio then you may have picked it up by accident.
  19. The plain javascript way to attach event listeners is to use the addEventListener method. Other than that it's the same. document.forms["formsignin"].addEventListener('submit', function(e){ if (!validateIt()){ e.preventDefault(); } }); function validateIt(){ //Do your validations return true; //or false } Do your validations and if your validation fails call e.preventDefault().
  20. Why do you want to call .submit() on the form? The way a submit handler is supposed to work is you do your validation and if it fails you cancel the submit event. Otherwise you allow the submit event to proceed and the browser will submit the form. $(myForm).on("submit", function(e){ if (!validateit()){ e.preventDefault(); } }); function validateit(){ //Do your validations //Return true or false }
  21. kicken

    Reading between two lines in text file

    So you want to start reading data at the 0 @F*@ FAM line, then stop when you either hit the next FAM line or hit the end of file right? <?php $fp = fopen('valkrider.txt', 'r'); $record = []; while (!feof($fp)){ $line = trim(fgets($fp)); if (isHeaderLine($line)){ if (!empty($record)){ doSomethingWithRecord($record); $record = []; } } $record[] = $line; } if (!empty($record)){ doSomethingWithRecord($record); } function isHeaderLine($line){ return strncmp($line, '0 @F',4) === 0; } function doSomethingWithRecord($record){ var_dump($record); } This code works by just gathering every line read into a record array until it encounters one of those header lines. When it finds a header line it processes the previous record (if any) then starts a new record array. At the end of the loop it will process the final record if one exists. I made the assumption that the header lines all begin with "0 @F". If that's not accurate you'll have to expand on that condition. I'm also assuming there are not lines you need to ignore at the start/end of the file. Again, if that's not true you'll need to make adjustments.
  22. kicken

    Reading between two lines in text file

    It would help if you included an example of the file you are reading and which lines are your start and stop lines.
  23. Create a function that looks for inputs with a specific attribute and then apply your date picker code to those. For example: jQuery(function($){ var defaultSettings = { format: 'yyyy/mm/dd', calendarWeeks: true, weekStart: 1, todayHighlight: true }; $('[data-datepicker]').each(function(){ var $input = $(this); var settings = $.extend($input.data('datepicker')||{}, defaultSettings); $input.datepicker(settings); }); }); Then in your HTML you just give your inputs the appropriate attribute. If you want to change the default settings, put the new settings as the attributes value. <input type="text" name="start" data-datepicker> <input type="text" name="end" data-datepicker> <input type="text" name="birthday" data-datepicker='{"format":"mm/dd/yyyy"}'>
  24. I'd guess that what you'd want to do is just create a temporary directory somewhere when you need to build an app for a user and create/modify your cordova project there. Make the temporary directory. Create your cordova project Apply whatever settings/customizations the user specified Execute the cordova command to build the apk Copy the apk off somewhere when done Delete the directory.
  25. Program Execution There are several options for running a program. exec() is most common in my experience.
×

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.