Jump to content

mcdrr

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mcdrr's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Here is what I currently have. My first query $result runs successfully and outputs correct data. I am not sure/quite understand how to on implement the $innerresult and also how would I print the results for $innerresult query? Am I missing code for fetching results for $innerresult? How would I select a db in the second query before it is run? On my first query I am doing a @mysql_select. Thanks again for all the help again I dont have to much experience with php and mysql. thanks again!!! //mysql query //being performed @mysql_select_db($Dragon_dbname) or die( "Unable to select database"); $result = mysql_query("select soc.dragon.datetime, soc.dragon.sensor, soc.dragon.signature, inet_ntoa(soc.dragon.source), inet_ntoa(soc.dragon.dest), soc.dragon.sourceport, soc.dragon.destport, soc.dragon.protocols from dragon where inet_ntoa(soc.dragon.source) like '" .$Drgsrc."' or inet_ntoa(soc.dragon.dest) like '" .$Drgsrc."' limit 1000", $conn2); if (!$result) { echo 'could not run query: ' . mysql_error(); exit; } $row = mysql_fetch_row($result); echo 'connected fetch'; if (!$row) { echo 'could not fetch records: ' . mysql_error(); exit; } while ($row = mysql_fetch_array($result) ) { $innerresult = mysql_query("select inet_ntoa(ip_src), inet_ntoa(ip_dst), layer4_sport, layer4_dport, timestamp, sig_name, sid, cid from acid_event where inet_ntoa(ip_src) like '" .$Src."' or inet_ntoa(ip_dst) like '" .$Src."' limit 1000", $conn1); echo '<tr>'; echo $row['rowname']; echo '<td align="center">',$row['inet_ntoa(soc.dragon.source)'],'</td>'; echo '<td align="center">',$row['inet_ntoa(soc.dragon.dest)'],'</td>'; echo '<td align="center">',$row['sourceport'],'</td>'; echo '<td align="center">',$row['destport'],'</td>'; echo '<td align="center">',$row['datetime'],'</td>'; echo '<td align="center">',$row['signature'],'</td>'; echo '<td align="center">',$row['sig_name'],'</td>';
  2. Well at this point my next question would be how would you guys go about running 2 queries on two different servers and printing the results. Can someone please give me an example. I need it to be all in one statement as I am using If Else statements. thanks for the help.
  3. Here is what I have. Can someone please point me in the right direction or if someone can double check my code. Thanks for all the help. //Connection to both MYSQL databases on two different servers. $conn1 = mysql_connect($Dragon_host,$Dragon_user,$Dragon_pass) or die (mysql_errno().": ".mysql_error()."<BR>"); $conn2 = mysql_connect($Snort_host,$Snort_user,$Snort_pass) or die (mysql_errno().": ".mysql_error()."<BR>"); //mysql query that is going //to be performed $result = mysql_query("select datetime, sensor, signature, inet_ntoa(source), inet_ntoa(dest), sourceport, destport, protocols from dragon where inet_ntoa(source) like '" .$Drgsrc."' or inet_ntoa(dest) like '" .$Drgsrc."'", $conn1); echo "connected successfully"; while ($row = mysql_fetch_array($result) ) { $innerresult = mysql_query("select inet_ntoa(ip_src), inet_ntoa(ip_dst), layer4_sport, layer4_dport, timestamp, sig_name, sid, cid from acid_event where inet_ntoa(ip_src) like '" .$Src."' or inet_ntoa(ip_dst) like '" .$Src."'", $conn2); echo '<tr>'; echo $row['rowname']; echo '<td align="center">',$row['datetime'],'</td>'; echo '<td align="center">',$row['sensor'],'</td>'; echo '<td align="center">',$row['signature'],'</td>'; echo '<td align="center">',$row['inet_ntoa(source)'],'</td>'; echo '<td align="center">',$row['inet_ntoa(dest)'],'</td>'; echo '<td align="center">',$row['sourceport'],'</td>'; echo '<td align="center">',$row['sig_name'],'</td>'; I am getting the following error. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource on line 31 which is while ($row = mysql_fetch_array($result) ) thanks,
  4. Actually the DB is on another server. I dont know if that makes a difference. thanks,
  5. Hi, I was wondering what the best way would be to connect to two different mysql databases using php. for example right now I have $connection = mysql_connect($user.... then the mysql query. then a loop. I want to add another query and connection to another db before the loop ends. Is that even possible? The main thing that I am looking to do is to echo/print the results of the each query before the next IF statement. thanks.
  6. Hi I was wondering if someone would be kind enough to help me out with the following questions. I am trying to do a query in mysql that will query a date table for a date entered up to the current date. For example if a user enters 2006-02-02 I would like to query from 2006-02-02 to todays date. How would the mysql query look like select ip_src, ip_dst, sport, dport, timestamp, sig_name from acid_event where timestamp between '2006-01-22%' and ?? how would I tell the following script to search for upto today. Or if there is a better way to do it please advice. thanks for the help and advice.
  7. Ok here is what I got so far. I have the following code below sorta working. The problem is that when I do a !isset statement it stops working. For example If I do this if (isset($_POST['Sdate']) && isset($_POST['Edate'])) it works FINE If I change it to this if (isset($_POST['Sdate']) && !isset($_POST['Edate'])) then I get a blank page for results. The other problem that I have is that if I add another if statement just like the one below (which is currenlty working, but with IP ADDRESS variables) neither the working one or the new one work. Again I just get a blank page. Here is the code that currently works for searching just for the dates. Like I said ONCE a new if isset statement gets added neither if statement works. So I guess my question is how would I add another if isset statement that works when the $_POST['Src']; variable is set instead of $_POST['Sdate'] like I have below. THANKS AGAIN FOR ANY HELP OR IDEAS!!! <table border="1" width="82%" cellpadding="1" cellspacing="2"> <th align="center">Source_IP</th> <th align="center">Destination_IP</th> <th align="center">Source_Port</th> <th align="center">Destination_Port</th> <th align="center">Date_Time</th> <th align="center">Signature</th> <th align="center">BASE_Link </th> <? $host = ""; $user = ""; $pass = ""; $dbname = ""; $Src = $_POST['Src']; $Sdate = $_POST['Sdate']; $Edate = $_POST['Edate']; $connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>"); mysql_select_db($dbname); //Query that is being run if (isset($_POST['Sdate']) && isset($_POST['Edate'])) { $query = "select inet_ntoa(ip_src), inet_ntoa(ip_dst), layer4_sport, layer4_dport, timestamp, sig_name from acid_event where (timestamp between '" .$Sdate."%' and '" .$Edate."%')"; print_r($query); $result = mysql_query($query) or die('Query failed: ' . mysql_error()); while ($line = mysql_fetch_row($result) ) { echo '<tr>'; echo '<td align="center">',$line[0],'</td>'; echo '<td align="center">',$line[1],'</td>'; echo '<td align="center">',$line[2],'</td>'; echo '<td align="center">',$line[3],'</td>'; echo '<td align="center">',$line[4],'</td>'; echo '<td align="center">',$line[5],'</td>'; } } ?>
  8. I am complely lost here. I am not sure what I am supposed to change the line below to. Before I had to add the if statements all my code was working before. I used the echo's below to print out each one of the columns which work just fine. Is there a better way to print out each query in the individual IF statements? echo '<td align="center">',$line[0],'</td>'; echo '<td align="center">',$line[1],'</td>'; echo '<td align="center">',$line[2],'</td>'; Here is what I have tried but not sure if I have added the print_r($query) in this code but get either no error or data results. Also what am I supposed to be replacing the ($)in the following if statement. if (isset($Src) && isset($Sdate)) is this any variable I want of am I supposed to define it somewhere? If anyone have any ideas it would be really helpful AS I AM COMPLETELY STUCK AND LOST. thanks for ALL the HELP. <table border="1" width="82%" cellpadding="1" cellspacing="2"> <th align="center">Source_IP</th> <th align="center">Destination_IP</th> <th align="center">Source_Port</th> <th align="center">Destination_Port</th> <th align="center">Date_Time</th> <th align="center">Signature</th> <th align="center">BASE_Link </th> <? $host = "xxxx"; $user = "xxxxx"; $pass = "xxxxx"; $dbname = "xxxxx"; $Src = $_POST['Src']; $Sdate = $_POST['Sdate']; $Edate = $_POST['Edate']; $connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>"); mysql_select_db($dbname); //Query that is being run if (isset($Src) && !isset($Sdate)) { $query = "select inet_ntoa(ip_src), inet_ntoa(ip_dst), layer4_sport, layer4_dport, timestamp, sig_name from acid_event where inet_ntoa(ip_src) like '" .$Src."' or inet_ntoa(ip_dst) like '" .$Src."'"; print_r($query) } if (!isset($Src) && !isset($Sdate)) { $query = "select inet_ntoa(ip_src), inet_ntoa(ip_dst), layer4_sport, layer4_dport, timestamp, sig_name from acid_event where (timestamp between '" .$Sdate."%' and '" .$Edate."%')"; print_r($query) } if (isset($Src) && isset($Sdate)) { $query = "select inet_ntoa(ip_src), inet_ntoa(ip_dst), layer4_sport, layer4_dport, timestamp, sig_name from acid_event where (timestamp between '" .$Sdate."%' and '" .$Edate."%') and (inet_ntoa(ip_src) like '" .$Src."' or inet_ntoa(ip_dst) like '" .$Src."')"; print_r($query) } //this will print the query results $result = mysql_query($query) or die('Query failed: ' . mysql_error()); //this is a line break before the spit output while ($line = mysql_fetch_row($result) ) { echo '<tr>'; echo '<td align="center">',$line[0],'</td>'; echo '<td align="center">',$line[1],'</td>'; echo '<td align="center">',$line[2],'</td>'; echo '<td align="center">',$line[3],'</td>'; echo '<td align="center">',$line[4],'</td>'; echo '<td align="center">',$line[5],'</td>';
  9. Here is the entire code that I have. I have made the changes per your advice. I am still having problems print any results. I replaced if ($IP) with $Sdate. not sure if that is right?? THANKS FOR ALL YOUR HELP. if (isset($Src) && !isset($Sdate)) <th align="center">Source_Port</th> <th align="center">Destination_Port</th> <th align="center">Date_Time</th> <th align="center">Signature</th> <th align="center">BASE_Link </th> <? $host = "localhost"; $user = "xxxxx"; $pass = "xxxx"; $dbname = "xxxxx"; $Src = $_POST['Src']; $Sdate = $_POST['Sdate']; $Edate = $_POST['Edate']; $connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>"); mysql_select_db($dbname); //Query that is being run if (isset($Src) && !isset($Sdate)) { $query = "select inet_ntoa(ip_src), inet_ntoa(ip_dst), layer4_sport, layer4_dport, timestamp, sig_name from acid_event where inet_ntoa(ip_src) like '" .$Src."' or inet_ntoa(ip_dst) like '" .$Src."'"; } if (!isset($Src) && !isset($Sdate)) { $query = "select inet_ntoa(ip_src), inet_ntoa(ip_dst), layer4_sport, layer4_dport, timestamp, sig_name from acid_event where (timestamp between '" .$Sdate."%' and '" .$Edate."%')"; } if (isset($Src) && isset($Sdate)) { $query = "select inet_ntoa(ip_src), inet_ntoa(ip_dst), layer4_sport, layer4_dport, timestamp, sig_name from acid_event where (timestamp between '" .$Sdate."%' and '" .$Edate."%') and (inet_ntoa(ip_src) like '" .$Src."' or inet_ntoa(ip_dst) like '" .$Src."')"; } //this will print the query results $result = mysql_query($query) or die('Query failed: ' . mysql_error()); //this is a line break before the spit output while ($line = mysql_fetch_row($result) ) { echo '<tr>'; echo '<td align="center">',$line[0],'</td>'; echo '<td align="center">',$line[1],'</td>'; echo '<td align="center">',$line[2],'</td>'; echo '<td align="center">',$line[3],'</td>'; echo '<td align="center">',$line[4],'</td>'; echo '<td align="center">',$line[5],'</td>'; } ?>
  10. Thanks again for the reply. How would I print the output for each if statement. Do I print it like I had it before?? Or do I have to print it out in a different way. thanks for you patience and help once again! $result = mysql_query($query) or die('Query failed: ' . mysql_error()); //this is a line break before the spit output while ($line = mysql_fetch_row($result) ) { echo '<tr>'; echo '<td align="center">',$line[0],'</td>'; echo '<td align="center">',$line[1],'</td>'; echo '<td align="center">',$line[2],'</td>'; echo '<td align="center">',$line[3],'</td>'; echo '<td align="center">',$line[4],'</td>'; echo '<td align="center">',$line[5],'</td>'; } ?>
  11. what would be the best way to do this if statement. Like I mentioned I am really new to all of this. I am trying to do if statements so that if a users wants to search the DB by just entering and IP address or just entering a date or entering both date and IP address the query will print out results. So for example how would I do if user enters just IP info on (but should this would be a query or something else) then print out the results if user enters just DATE info then print out the results if user enters both IP and DATE info then print out the results thanks for the HELP I really appreciate it.
  12. Here is what I changed the code to. I am unable to get any results. Can anyone point me in the right direction as to where/what is wrong with this code? Am I supposed to print the results after every if statement? If so can someone give me an example. if { $query = "select inet_ntoa(ip_src), inet_ntoa(ip_dst), layer4_sport, layer4_dport, timestamp, sig_name from acid_event where inet_ntoa(ip_src) like '" .$Src."' or inet_ntoa(ip_dst) like '" .$Src."'"; } else if { $query = "select inet_ntoa(ip_src), inet_ntoa(ip_dst), layer4_sport, layer4_dport, timestamp, sig_name from acid_event where (timestamp between '" .$Sdate."%' and '" .$Edate."%')"; } else { "select inet_ntoa(ip_src), inet_ntoa(ip_dst), layer4_sport, layer4_dport, timestamp, sig_name from acid_event where (timestamp between '" .$Sdate."%' and '" .$Edate."%') and (inet_ntoa(ip_src) like '" .$Src."' or inet_ntoa(ip_dst) like '" .$Src."')"; } $result = mysql_query($query) or die('Query failed: ' . mysql_error()); //this is a line break before the spit output while ($line = mysql_fetch_row($result) ) { echo '<tr>'; echo '<td align="center">',$line[0],'</td>'; echo '<td align="center">',$line[1],'</td>'; echo '<td align="center">',$line[2],'</td>'; echo '<td align="center">',$line[3],'</td>'; echo '<td align="center">',$line[4],'</td>'; echo '<td align="center">',$line[5],'</td>'; } ?> THANKS AGAIN FOR THE HELP
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.