PHP Running/GET Statements - mysql

I need help with Get Statements and Running on a site on PHP
I have this a my PHP code
This is how I save it but it only saves username ...
http://example.com/NC0.php?U=namehere
I have tried this below but it doesn't work
http://example.com/NC0.php?U=namehere?P=passhere
How can I make it like........ NC0.php?U=namehere?P=passhere
or something similar thanks!!!

You are using the ? multiple times. It is meant to start the query! To have multiple parameters in the URL you use the & symbol to differentiate the parameters.
For example,
http://example.com/NC0.php?U=namehere&P=passhere

Related

Gatling and variations in csv-file (feeder)

Having this exec in Gatling:
.exec(http("Sykdomsinfo")
.get("https://xxx/contentapi/v1/xxx")
.headers(headers_1)
.queryParam("Sykdomtilstand","${sykdomtilstand}")
.queryParam("Maalgruppe","${maalgruppe}")
.check(status.is(expected = 200)))
and using feeder like this:
.feed(csv("magnus/ContentAPI.csv").circular)
and the csv-file looking like this:
sykdomtilstand,maalgruppe
35489007,133936004
11381005,
363354003
I weant to run a simulation that for some users execute the request using two parameters (the first line in csv-file) while other users only execute wit one parameter. I want to simulate different and randomly.
What would be the best approach to accomplish this? I understand that it wont work as it stands now because of the unbalanced csv-file structure.
May be a csv like below can help. As passing & does not make any change in the URL.
sykdomtilstand,maalgruppe
35489007,133936004
11381005,&
363354003,&

CakePHP Error: SQLSTATE[42S02] table not found - but exist

You might read this question every day so i tried another Stackoverflow's answer before asking:
CakePHP table is missing even when it exists
Anyways. The table i try to select data from does exist (quadra-checked uppercase/lowercase!) and it gets also listed via $db->->listSources().
Here's a screenshot of the query, the message and the last result from listing all Datasource's tables:
http://i.stack.imgur.com/CdhcV.png
Note: If i run this query in PHPMyAdmin manually it works fine. I would say its impossible to get the pictures output at one time in a view - now its up to you to tell me the opposite. By the way: I am pretty sure to use the correct Datasource.
I should tell additionally that the mysql-server is hosted on another platform. Since i can use it for my localhost-phpmyadmin if i modify the config.inc.php i can promise it is no Firewall-Problem.
Written in behalf of xcy7e:
The mistake was to execute the Query from the local Model. Here's the code:
$conn = ConnectionManager::getDataSource('myDB');
$conn->query($query);
// instead of $this->query($query);

Get Redmine custom field value to a file

I'm trying to create a text file that contains the value of a custom field I added on redmine. I tried to get it from an SQL query in the create method of the project_controller.rb (at line 80 on redmine 1.2.0) as follows :
sql = Mysql.new('localhost','root','pass','bitnami_redmine')
rq = sql.query("SELECT value
FROM custom_values
INNER JOIN projects
ON custom_values.customized_id=projects.id
WHERE custom_values.custom_field_id=7
AND projects.name='#{#project.name}'")
rq.each_hash { |h|
File.open('pleasework.txt', 'w') { |myfile|
myfile.write(h['value'])
}
}
sql.close
This works fine if I test it in a separate file (with an existing project name instead of #project.name) so it may be a syntax issue but I can't find what it is. I'd also be glad to hear any other solution to get that value.
Thanks !
(there's a very similar post here but none of the solutions actually worked)
First, you could use Project.connection.query instead of your own Mysql instance. Second, I would try to log the SQL RAILS_DEFAULT_LOGGER.info "SELECT ..." and check if it's ok... And the third, I would use identifier instead of name.
I ended up simply using params["project"]["custom_field_values"]["x"] where x is the custom field's id. I still don't know why the sql query didn't work but well, this is much simpler and faster.

mysql and php views

i am writing a html form, that simply passes data to a php one, and then to an sql database.
my question is, should view be stored in php or sql (and call them from php)?
i could do that. the problem is that in my views i have variables. i.e each time i call them i have different parameters in them.
so my php code looks like this:
$this->query = "SELECT student.gender FROM student WHERE email ='$this->email'";
if i put the above view in mysql, i can't use a variable like "email" right?
so where are view better to be stored?
same goes for procedures ?
$this->query = sprintf("SELECT student.gender FROM student WHERE email ='%s'", $this->email);

regarding database security

I am using prepared statements with mysqli(); to insert and retrieve data on my website also i used bind_param so i don't add variables directly into the query.I used strip_tags to clean any inputs what else should i look out for ?
Don't use strip_tags() on database input: use htmlentites() (or urlencode() where appropriate) on browser output.