Tuesday, August 6, 2019

windows server 2008 r2 - runas with administrator privileges

I'm having some problems with running the command prompt with administrator privileges.


I'm use this command, to run as a specific user:


runas /user:DOMAIN\MYUSER cmd


The user DOMAIN\MYUSER is member of DOMAIN\Domain Administrators who are in the local Administrators group.


But when I try to run net start/stop MyService I get an access denied error. Any suggestions?

Monday, August 5, 2019

forms - Parse error: syntax error, unexpected '(' in D:xampp3xampphtdocscontact.php on line 10




I have a problem with my code here.
I'm making a simple "Contact us" via html / PHP.
But i'm new to all this, and learning it from step to step. So thats why i've come here.
I get this error: Parse error: syntax error, unexpected '(' in D:\xampp3\xampp\htdocs\contact.php on line 10 and here is the code:



include 'core/init.php';
include 'includes/overall/header.php';
if (empty($_POST) === false) {

$name = $_POST ['name'];
$email = $_POST ['email'];
$message = $_POST ['message'];

if (empty($name) === true || (empty( ($email) === true || (empty($message === true) {
$errors[] = 'Name, email and message are required!';
} else {

}
?>


Answer



Try this:



include 'core/init.php';
include 'includes/overall/header.php';
if (empty($_POST) === false) {

$name = $_POST ['name'];
$email = $_POST ['email'];
$message = $_POST ['message'];

if (empty($name) === true || empty($email) === true || empty($message) === true) {
$errors[] = 'Name, email and message are required!';
} else {
}
// The else above is actually not needed thus you could remove it.

}
?>


r - How can we make xkcd style graphs?




Apparently, folk have figured out how to make xkcd style graphs in Mathematica and in LaTeX. Can we do it in R? Ggplot2-ers? A geom_xkcd and/or theme_xkcd?



I guess in base graphics, par(xkcd=TRUE)? How do I do it?



xkcd#1064



As a first stab (and as much more elegantly shown below) in ggplot2, adding the jitter argument to a line makes for a great hand-drawn look. So -



ggplot(mapping=aes(x=seq(1,10,.1), y=seq(1,10,.1))) + 

geom_line(position="jitter", color="red", size=2) + theme_bw()


It makes for a nice example - but the axes and fonts appear trickier. Fonts appear solved (below), though. Is the only way to deal with axes to blank them out and draw them in by hand? Is there a more elegant solution? In particular, in ggplot2, can element_line in the new theme system be modified to take a jitter-like argument?


Answer



You might want to consider the following package:



Package xkcd: Plotting ggplot2 graphics in a XKCD style.



library(xkcd)

vignette("xkcd-intro")


Some examples (Scatterplots, Bar Charts):




  • Scatterplot:



Scatterplot





  • Bar Chart:



Bar Chart


r - Data frame to numeric?




I have a data.frame with the following structure :




str(P)
'data.frame': 24 obs. of 5 variables:
$ vH : Factor w/ 101 levels "[Hz]","[m/s]",..: 34 51 66 71 76 78 83 4 9 11 ...
$ P_el: Factor w/ 48 levels " ","[dB(A)]",..: 26 18 27 34 15 17 20 21 24 23 ...
$ CP : Factor w/ 92 levels "-"," ","[-]",..: 30 39 41 44 45 43 40 37 35 33 ...
$ CT : Factor w/ 68 levels " ","[-]","[kg/m³]",..: 4 4 4 4 4 4 4 4 4 4 ...
$ TSR : Factor w/ 87 levels "-"," "," -20 to 45",..: 35 32 76 75 75 74 72 69 67 66 ...

head(P)
vH P_el CP CT TSR

31 3 41 0.152229609724618 0 15.8
32 4 231 0.36183539476084 0 11.8
33 5 528 0.423450793411543 0 9.6
34 6 957 0.444157733251402 0 9.5
35 7 1524 0.445420179261082 0 9.5
36 8 2242 0.438979954033443 0 9.1


How could I get the numeric columns without doing a for loop :




n=ncol(P)
for(j in 1:n){P[,j]=as.numeric(as.character(P[,j]))}


I have tried data.matrix(P) but it does not work !


Answer



Here's a dplyr solution that uses mutate_all



library(dplyr)
P %>%

mutate_all(as.character) %>%
mutate_all(as.numeric)

PHP form to search data in MySQL db

I try to open this post to receive some help about a problem with a search form that doesn't work correctly.



I have a MySQL DB with some data stored in different tables:



DB is: list_pec
Table are: pec_1, pec_2, pec_3 and pec_4




All of these tables contain the same rows with different data. Rows are
firstame, lastname, email, id_client, id_2client



My goal is to create a search form in PHP in which there are an input label and a selection form that is used to connect to the database and give me as an output query result.



Below PHP file to connect MySQL DB that I called "conn.php"



$host = "localhost";

$userName = "demo";
$password = "demo";
$dbName = "list_pec";

// Create database connection
$conn = new mysqli($host, $userName, $password, $dbName);

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);

}
?>


below file called "search.php" in which there's form and php code, obv i want have query result in the same .php file so i used in form action



error_reporting(E_ALL);
ini_set('display_errors', '1');
include("conn.php");


$search_output = "";
if (isset($_POST["submit"])){
if($_POST['option']== "a"){
$sqlcommand="SELECT email, id_client, id_2client FROM pec_1 WHERE email = 'email'";
}

else if ($_POST['option'] == "b"){
$sqlcommand="SELECT email, id_client, id_2client FROM pec_2 WHERE email = 'email'";
}


else if ($_POST['option'] == "c"){
$sqlcommand="SELECT email, id_client, id_2client FROM pec_3 WHERE email = 'email'";
}

else if ($_POST['option'] == "d"){
$sqlcommand="SELECT email, id_client, id_2client FROM pec_4 WHERE email = 'email'";
}




$query = mysqli_query($conn,$sqlcommand) or die (mysqli_error($conn));
$search_output .="
query result: ";
if ($row = mysqli_fetch_array($query)){
$email = $row ["email"];
$pec = $row ["id_client"];
$sdi = $row ["id_2client"];
$search_output .= "

$email - $id_client - $id_2client

";



} else{
$search_output= "
No Result";

}
}
?>





Search id_client and id_2client





Search id_client and id_2client