Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
Digital Lifestyle
Web Design and Hosting
PHP / mySQL Project help
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="djames42" data-source="post: 396069" data-attributes="member: 13241"><p>For what it's worth, here's a very simple snippet of code I just hacked together. This takes a few parameters pushed to it by way of wget (which, if you're not familiar with, is a way of emulating a web browser in code to pass a URL to a server and retrieve any html pushed from that server). It takes the passed parameters and loads them into a local mysql database. You should be able to use this to see a very simple way of putting data in to your database. Getting it out is slightly more complicated, but not much...</p><p></p><p>[CODE]<?PHP</p><p></p><p>$server=$_GET['server'];</p><p>$sessioncnt=$_GET['sessioncnt'];</p><p>$totalsessions=$_GET['totalsessions'];</p><p>$date=date('Y-m-d H:i:s');</p><p></p><p>$db_conn = mysql_connect('localhost', '[I]username[/I]', '[I]password[/I]');</p><p>if (!$db_conn) {</p><p> die('Could not connect: ' . mysql_error());</p><p>}</p><p></p><p>$db_selected = mysql_select_db('[I]database_name[/I]', $db_conn);</p><p>if (!$db_selected) {</p><p> die ('Can\'t use database_name : ' . mysql_error());</p><p>}</p><p></p><p>$insert=sprintf("insert into session_history values('%s','%s',%d,%d)",</p><p> mysql_real_escape_string($server),</p><p> mysql_real_escape_string($date),</p><p> $sessioncnt, $totalsessions);</p><p></p><p>mysql_query($insert,$db_conn);</p><p>mysql_close($db_conn);</p><p></p><p>?>[/CODE]</p><p></p><p></p><p>The way this script is called is by running the following command:</p><p></p><p>[CODE]wget -q --delete-after "http://web_url/~user/path/scrpt.php?server=${hostname}&sessioncnt=${usedprocs}&totalsessions=${maxprocs}"[/CODE]</p></blockquote><p></p>
[QUOTE="djames42, post: 396069, member: 13241"] For what it's worth, here's a very simple snippet of code I just hacked together. This takes a few parameters pushed to it by way of wget (which, if you're not familiar with, is a way of emulating a web browser in code to pass a URL to a server and retrieve any html pushed from that server). It takes the passed parameters and loads them into a local mysql database. You should be able to use this to see a very simple way of putting data in to your database. Getting it out is slightly more complicated, but not much... [CODE]<?PHP $server=$_GET['server']; $sessioncnt=$_GET['sessioncnt']; $totalsessions=$_GET['totalsessions']; $date=date('Y-m-d H:i:s'); $db_conn = mysql_connect('localhost', '[I]username[/I]', '[I]password[/I]'); if (!$db_conn) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db('[I]database_name[/I]', $db_conn); if (!$db_selected) { die ('Can\'t use database_name : ' . mysql_error()); } $insert=sprintf("insert into session_history values('%s','%s',%d,%d)", mysql_real_escape_string($server), mysql_real_escape_string($date), $sessioncnt, $totalsessions); mysql_query($insert,$db_conn); mysql_close($db_conn); ?>[/CODE] The way this script is called is by running the following command: [CODE]wget -q --delete-after "http://web_url/~user/path/scrpt.php?server=${hostname}&sessioncnt=${usedprocs}&totalsessions=${maxprocs}"[/CODE] [/QUOTE]
Verification
Name this item 🌈
Post reply
Forums
Digital Lifestyle
Web Design and Hosting
PHP / mySQL Project help
Top