Pull data from MySQL and reuse for a pingscript in PHP - php

I'm usually not the "scripting" guy
but I have been given a task, to create a script, that ping all our network equipments. (~300 devices) so I have come so fat, we can manage and edit the Excel and export as CVS into MySQL database, so far...
I have been searching around for a valid example to directly use the "IP" table from the database into my pingscript or to pull the SQL data and insert into a Array..
However, I have contact with the database, but I am unable to print the array data into my ping script however.
When I do a ECHO ['$databasename']; I get the result out, but I don't figure how to correctly input the table "IPaddr" into pingscript as a foreach from array...
I hope you can help me clearing this issue or correct me where I'm wrong :)
I can't post the code here, the site gives an error, so i posted on Pastebin:
PHP script can be seen here

Related

many whitespaces in string after reading of database

I have the a textarea with the following value:
I save this value with php into my mysql database.
The result looks like this via phpmyadmin:
Now, I send a query with php to get the result and to show this text like this, to show it with line breaks:
<? echo nl2br($row->text); ?>
But the result will shown many withspaces. here the source code:
Where is my fault? :/
The result looks like this via phpmyadmin
phpadmin ist a webpage with html, it doesn't show consecutive blanks.
Where is my fault? :/
Somewhere between reading it out of the textarea, writing it into the database and reading it back from there.
Steps to track your problem.
What is transferred from the textarea to the server?
Check how the value is in your database.
Output the length of this string to get a simple idea of what really is in the database.
Then if you know if the string already got wrong into the database or the error occurs only when reading it, you can go on looking at this particular place.

Looping mysql Table Values on a CSS Table

I have a table with date/time, temperature and humidity data stored on a mysql database.
I have a ugly looking but working HTML one so I made a new CSS table using templates and wanted to use the looping in PHP (as in the HTML) to fetch data to the table using the table designers format. (Some datas are manually in as in the sample table photo)
I want to automate that but my PHP script has a problem and does not load the page. shows error.
Im very new to LAMP environment actually and unsure if I can use class variables inside the PHP script without changing anything.
My table looks like this without the python script: https://imgur.com/a/WmpHzMZ
The code is here: https://codeshare.io/amvPYw
(I cannot add code here, it says bad formatting everytime)
Html element tags are close like </tr>. See your end line in while loop.

Which way is better to send data by POST method in objective-C?

I am moving data from sqlite to webserver (mySql), from iphone to web and php will be landing site which insert data in mysql after getting data in POST format.
I am using NSURLConnection in iOS. I am confused how to move data, so I figured out that I should append all the data in string from a table seperated by comma and \n for row. Since data consist complete postal address(name, address, phone, email) and maximum record might be 500, don't know if there are other better ways.
My options are:
Send each line of row after reading data from table
Sending whole data in one single variable(string)
I don't know.
Please suggest me.
I recommend POST method and because POST has no limit of characters you can do the whole database to your mysql.
I should make in PHPmyAdmin (or something similar) an export or an backup and send that to your mysql.

How can I sort multiple tables i export from an sql database to excel by date?

I have searched for help with this extensively but haven't been able to figure it out. This is my first attempt at asking a question here so please bare with.
I have a project called www.farmathand.com where farmers keep track of their field activities through multiple pre-defined forms and a few dynamic forms. These forms then have an associated date with them to keep a record of when something was done. Here's a screen shot
Farmers have the ability to export all their entered information into an excel file. The problem I am having is figuring out a solution so sort the activities by date. Currently I have simple export code that looks and print data from each table (i.e. each type of activity) then moves on the to the next able. The fields in each table differ as you can see in the image.
Here is a screen shot of an excel file for the above example:
What i would like to be able to do is sort the activities by the date. So in the example in the above image. Line 7 would be at the top or like one should be line 6.
I was wondering if anyone had any suggesting or could guide me to the appropriate reference. The data base is a mysql database. I'm running php scripts currently.
If I understand your question correctly then what you want is to include an ORDER BY clause in your select query to sort the data. More information here:
http://dev.mysql.com/doc//refman/5.0/en/sorting-rows.html

php source related question

i have some php source it can send form data info to other page under mysql 4.x version.
but after upgraded to mysql 5.x version, this php source can't send form data info to other page.
i was searched many info, but don't have idea what's wrong with my php source.
i just can guess this is related with mysql upgrade and i have to edit my php source,
but lack of knowledge it very tough for me.
if anyone help me or give some hint it really appreciate!
my php source is consist of 3 part.
form sender page ( http://pastebin.com/3Sg7SyWV )
-> submited form data info checking page ( http://pastebin.com/WEx5tEn2 )
-> insert form data to DB ( http://pastebin.com/918iZkgw )
for several day i was search and search but lack of my knowledge about php and mysql
it very hard to resolve.
Thanks in advance
You're not checking if your insert query succeeds. I can't tell which MySQL library you're using, but generally they all return FALSE if a query fails, so you could change your query line to something like:
$DB->ExecSql($InsertQuery) or die($DB->whatever_returns_error_information());
If something's wrong with the query, then this would abort the script and output any error information produced.
As well, it doesn't look like you're escaping your query data anywhere. That leaves you wide open to SQL injection. And as well, any of the form data which contains even a single quote (') will "break" the query by introducing syntax errors. If you had proper error checking in there, you'd have gotten a syntax error report.
For that matter, where are you extracting the submitted data and building all those variables you paste into the query? There's only one place in your three scripts where $_POST is referred to, and it seems to be in an error output function which simply dumps out each key/value as hidden form fields (and in there you're also not escaping/quoting the data, so your form itself is vulnerable to XSS attacks).

Categories