Jump to content

superkingkong

Members
  • Posts

    46
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

superkingkong's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. thanks, i managed to figure it out. I must use alias what i did earlier was, using inet_ntoa on select statement, then on displaying, i use $row['ipaddress'], which is not working. after using expression with alias, AS IP, no problem now thanks
  2. Basically any time you use an expression. thank you for the info
  3. thanks a lot i've learnt some thing new today btw, how do i know when do i need to use alias or like the one above ? thanks.
  4. If you converted all the row to integer you don't need inet_ntoa() anymore. Except maybe when you want to insert new row. right now, it's integer in mysql, but i need to show the result on the web page. so, by just pulling it straight it out, it only display 10 int. how can i use the NTOA or ATON to display it as dotted ip address (on mysql side). thanks.
  5. hmm... strange. I'm using datetime as the datatype, and the field name is datetime initially i was using timestamp, but changed it to datetime. $result = mysql_query("SELECT id, referrer, DATE_FORMAT(datetime, '%W %M %Y'), timezone, ipaddress, hostname, page, useragent FROM weblog ORDER BY id DESC"); echo "<table border=2>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo '<td><a href="' . $row['referrer'] . '">Referrer</a> 22</td>'; echo "<td>" . $row['datetime'] . " (" . $row['timezone'] . ") 33</td>"; echo "<td>" . $row['page'] . " 44</td>"; echo "</tr>"; echo "<tr>"; echo "<td>" . long2ip($row['ipaddress']) . " </td>"; echo "<td>" . $row['hostname'] . " </td>"; echo "<td>" . $row['useragent'] . " </td>"; echo "</tr>"; } echo "</table>";
  6. hi guys, I'm trying to display the datetime field with a particular format, unfortunately it is not showing anything using the date_FORMAT () function. if i remove the date_FORMAT () function, it is displaying YYY-MM-DD HH:MM:SS here is my select statement. $result = mysql_query("SELECT id, referrer, DATE_FORMAT(datetime, '%W %M %Y'), ipaddress, hostname, page, useragent FROM weblog ORDER BY id DESC"); would appreciate if you can please help, thanks.
  7. thank you very much I did backup my table earlier i knew that i'll do something wrong anyway, i have another question, now that everything is in the right order, i'm trying to display the table. Unfortunately, the ipaddress field is not showing anything (if i use the INET_NTOA()), but it shows integer if i use without the inet_ntoa function. Appreciate if you could help further, thanks. <?php $result = mysql_query("SELECT id, INET_NTOA('ipaddress'), referrer, datetime, page, hostname, useragent FROM weblog ORDER BY id DESC"); echo "<table border=2>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo '<td><a href="' . $row['referrer'] . '">Referrer</a> </td>'; echo "<td>" . $row['datetime'] . " (" . $row['timezone'] . ") </td>"; echo "<td>" . $row['page'] . " </td>"; echo "</tr>"; echo "<tr>"; echo "<td>" . $row['ipaddress'] . " </td>"; echo "<td>" . $row['hostname'] . " </td>"; echo "<td>" . $row['useragent'] . " </td>"; echo "</tr>"; } echo "</table>"; ?>
  8. thanks for the reply. i've done a script, it ran successfully, but when i look at the table, the ipaddress field is showing the same value "1176924178" for all the 2000+ records. is it supposed to be like that? or is my logic wrong? i'm just a newbie in PHP would appreciate if someone could please help. below is the code: btw, i've tried the INET_ATON or the ip2long, both also showing the same result. All ips int are the same. As you suggested, i'm doing it on a varchar(15) datatype field. It is still the same result after i converted it to int(12) unsigned $result = mysql_query("SELECT * FROM weblog"); while($row = mysql_fetch_array($result)) { $ipaddress = ip2long($row['ipaddress']); // $upd = mysql_query("UPDATE weblog SET ipaddress = INET_ATON('$ipaddress')"); $upd = mysql_query("UPDATE weblog SET ipaddress = $ipaddress"); if (!$upd) { echo "<br />Failed to update"; } else { echo "<br />Success!"; } } ?>
  9. hi guys, i have a table with ip address as varchar15 datatype. I need to convert it to int. how can i do that? appreciate your help, thanks.
  10. thanks. That means, if i want specific date and time format, i won't be able to use the timestamp/datetime for mysql, right? in my case above, i will have to create a varchar field of 38? thanks
  11. thanks for the fast reply. so, the date(... ) will be replacing now() - during insertion into mysql or it's only for displaying the date? and i still use now() to insert date? sorry, i'm new in php-mysql. i know the datetime format in mysql. just that, i'm not sure, after it is inserted into mysql in YYYY-MM-DD HH:MM:SS format, can i still change/manipulate the format for displaying purpose? thanks.
  12. Hi guys, I've managed to insert the timestamp into mysql using now() but to display the date on the report, i would like it to be displayed in this format. would that be possible? Thu, Apr 9, 2009 (CDT) at 02:49:52 PM i need it this way because previously i was using a flat text db, and all records have this format as the 'datetime' field. my second problem would be "importing" this text file into the same table. btw, the current table has the 'datetime' field of timestamp type. appreciate your help, thanks.
  13. thanks... it works btw, why you don't use numbers as get variables in URLs? i did a search and manage to find another function, query_string. is it the same or less reliable than get? thanks.
  14. Hi guys, how can I get certail value from a uri and do if statement? eg, url: http://geocities.com/~myusername/file.php?1 url: http://geocities.com/~myusername/file.php?2 url: http://geocities.com/~myusername/file.php?3 if ($_SERVER['REQUEST_URI'] == 1) do this elseif == 2 do this else do this I'm a newbie in php, appreciate if you could help me, thanks.
×
×
  • 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.