vendredi 1 janvier 2016

Calling C from Express.js?

What are best practices for doing this?

I have a program written in C that does some number crunching. This needs to be used by a site which is written using Express.js via Node. What's the best way to interface the two together?

Do I do something like this in JavaScript

exec("./foo -parameters here") 

or is there a better way to go forward?




How to insert records to a many to many relationship table on an sql database using php?

I just started PHP and am encountering a problem with php where the sql command shown below does not execute (inserts records into a many to many relationship table) when calling it with php while it works perfectly when manually inserting it with mysql command line interface. I am using $ds and $da (manual inputs) instead of making use of sessions to make sure that the command is executed. Noting that I have other mysql queries and work perfectly fine when executed through php using the same database connection as the one shown hereunder.

$connectionStatua = connect_db();
mysqli_query($connectionStatus, $sql);

$username = $_SESSION["username"];
$ds = "dekna";
$da = "dsa.jpg";
$query="INSERT INTO `tbl_users_files` (`user_ID`, `file_ID`)
SELECT `u.id`, `f.id` FROM `users` as `u` CROSS JOIN `tbl_uploads` as `f`
WHERE `username` = '$ds' AND `file` = '$da'";
mysqli_query($connectionStatus, $query);




html agility pack in c# that scrapes urls [duplicate]

This question already has an answer here:

Hi I am trying to write a method that will scrape urls with the html agility pack in the nuget packages. I am new to this package and I am getting a null reference exception by the foreach loop below. Can someone help me out and perhaps show me what I am doing wrong and to properly write code with this package that can scrape a web page for the url links. Thanks:

edit: I am not asking what is a null reference exception, I am saying I don't exactly understand what I am doing that I am receiving this exception.

code:

public static List<string> ParseLinks(string html)
    {
        HashSet<string> list = new HashSet<string>();
        var doc = new HtmlDocument();
        doc.LoadHtml(html);
        var nodes = doc.DocumentNode.SelectNodes("//a[@href]");
        foreach (var n in nodes)
        {
            string href = n.Attributes["href"].Value;
            list.Add(href);
        }
        return list.ToList();
     }




Website styling not being applied. (Calling stylesheet.css from a php include)

Good afternoon, and Happy New Year! I wonder whether anyone could help me resolve some problems I'm having in creating a website using html, css...and php for the first time. (My previous attempts at web design were only in html and css).

The problem at present is that my home-page (index.php) somehow isn't 'seeing' my stylesheet.css.

The code for the index.php is basically as follows :

    <?php
      $page_title='Home';
      [php-code here, to call in include1.php.....Please see below for details]
    ?>
    <div class="copy">
      [page content here, in html]
    </div>
   <?php
      [php-code here, to call in include2.php.....Please see below for details]
?>

My folder structure is : web

   css
     stylesheet.css
   images
     logo.png
   includes
     include1.php
     include2.php
   index.php

In attempting to call in include1.php (containing doc type declaration, and Head section including reference to stylesheet.css), I've tried the following (inserted between , as shown above), all without success :

$pathtoinclude1 = $_SERVER]'DOCUMENT_ROOT'];
$pathtoinclude1 .= "/includes/include1.php";
include_once($pathtoinclude1);

and

include('/includes/include1.php')

In include1.php, my reference to the stylesheet.css is :

<link rel="stylesheet" href="../css/stylesheet.css" media="Screen" type="text/css"/>

When I preview the home-page, all I get is the text in default font (Times New Roman?). None of the styling via css is being applied.

Can anyone give me some pointers as to what I'm doing wrong, please ? This is driving me a bit potty, and holding me back badly.

Any help much appreciated. Thank you.




How can I use Urdu in Webpages?

I want to use Urdu in my webpage to develop a website in Urdu Language... Please help me out, how can I find my required Webpage using Urdu Language?




php load database side-by-side

<?php
        try {

            $stmt = $db->query('SELECT postID, postTitle, postDesc, postDate FROM blog_posts ORDER BY postID DESC');
            while($row = $stmt->fetch()){

                echo '<div>';
                    echo '<h1><a href="viewpost.php?id='.$row['postID'].'">'.$row['postTitle'].'</a></h1>';
                    echo '<p>Posted on '.date('jS M Y H:i:s', strtotime($row['postDate'])).'</p>';
                    echo '<p>'.$row['postDesc'].'</p>';             
                    echo '<p><a href="viewpost.php?id='.$row['postID'].'">Read More</a></p>';               
                echo '</div>';

            }

        } catch(PDOException $e) {
            echo $e->getMessage();
        }
    ?>

This code loads the data by rows. I need to load the data side by side.. Any quick helps...




PHP not fetching data from online MYSQL database

Hosting a website on bigrock. Image below shows the servername, username, dbName, tableName and tableStrucutre

[see image]

The table contains two rows, but my PHP code is unable to fetch anything.

Code:

<?php
$servername = "208.91.198.197:3306";
$username = "sr";
$password = "##";
$dbName = "srohi5";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname) or die("Connection failed: " . $conn->connect_error);

$sql = " SELECT * FROM charities ";
$result = $conn->query($sql);

echo intval($result->num_rows);
$conn->close();
?>

It is able to establish a connection with the database, but is unable to execute/fetch any data. The output is:

0

Please help!