Jump to content

lukerodham

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

lukerodham's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Awesome thank you, its worked but the date is incorrect, its showing a time and date from yesturday. but that ok i'll try and work out how to get the proper date. THANK YOU
  2. Sorry i thought i added that, what im looking for is 1 ip and its latest date. is this possible?
  3. hi, im trying to use the DISTINCT mysql command to select unique ip's that have visited my site, but im also trying to get the rest of the rows data aswell so i can output the date and time that they visited. i ran into the problem that i can output the ip but no date and time. but if i add the the 'date' in the query line i dont get a unique output as i believe the it looks for a DISTINCT ip and date then. i have the code below to help you understand a bit more. but could some please help me as i can get the right output. thanks. $unique_query = mysql_query("SELECT DISTINCT ip, date FROM ip ORDER BY date DESC LIMIT 10"); while($uniquerow = mysql_fetch_array($unique_query)){ echo "<table width='100%' border='0' align='center'> <tr> <td width='50%' align='center' valign='middle' class='aboutme'>".$uniquerow['ip']."</td> <td width='50%' align='center' valign='middle' class='aboutme'>".$uniquerow['date']."</td> </tr> </table>"; } this is the output atm.
  4. Hey guys for some reason the code below, will insert into the data the information required even if there is the same email address already registered, have i done something wrong? $query = mysql_query("SELECT * FROM users WHERE email=$email"); $count = mysql_num_rows($query); if($count==0){ mysql_query("INSERT INTO users VALUES(NULL,'$firstname','$lastname','$email','$password','$day','$month','$year','$sex')") or die(mysql_error()); echo "Well done. Passwords match"; } else { echo "Please use another email as this one is already registered."; }
  5. ive just looked at the file where the value is held and there is not whitespace in front of the value and no behind. i do have the comma there that is trimmed but thats it. could there be a problem with the file_get_contents action that i have written?
  6. hey guys thanks for the quick response. i thought that this would be the case im getting this error: Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'localhost ' (11004) but i dont understand why.
  7. Hi, this is more of a question than asking for help so if its in the wrong section could someone please move. my question is could you connect to a database by using an array that has been generated from getting contents from a file, for example... $file_c = file_get_contents("example.txt"); $colms = explode(",",trim($file_c)); mysql_connect("$colms[0]","$colms[1]","$colms[2]") or die(mysql_error()); mysql_select_db("$colms[3]") or die(mysql_error()); if not how else would someone go about doing this.
  8. ok well what i was aiming for was to create a unique ip database, for a stats page and with the WHERE clause would i then just use the mysql_num_row function to check if there is already an entry for the $guestip. if you understand what i mean.
  9. Hey guys for some reason this code is not working i can't see a problem myself could someone please have a look and point the issue out to me. what i mean by it not working is it won't insert into the database or show a mysql_error. thanks in advance $guestip = $_SERVER['REMOTE_ADDR']; $time = date('G:i'); $date = date("y-m-d"); $query = mysql_query("SELECT * FROM IP_Address") or die(mysql_error()); while($row = mysql_fetch_assoc($query)){ if($guestip != $row['ip']){ //insert into db. mysql_query("INSERT INTO IP_Address(id, ip, date, time) VALUES(NULL,'$questip','$date','$time')") or die(mysql_error()); echo "inserted in to database"; echo mysql_error(); }else{ // add hit count and update time and date. echo "already in db"; } }
  10. Hey guys just wondering if this piece of code is correct because i get a mysql error saying Duplicate entry '*********' for key 2 this is the code i have and table structure. $sql = " INSERT INTO `IP_Address` VALUES(NULL,'".$ip."','".$date."','".$time."') ON DUPLICATE KEY UPDATE `date` = `".$date."`, `time` = `".$time."` ";
  11. ok thank you very much been a great help with only a few words
  12. ok thanks for the quick reply, i dont mean to sounds dumb but how else would i go about achieving what im looking for?
  13. hey guys how you all doing? ok im really looking for some help i've been playing with this code for quite some time now and still not got the hang of it. i'm currently trying to code a dynamic website as a portfolio for my designs and im trying to get to view the news.php file with an 'id' to view in the index file using an include() but for some reason its not happening very well. i keep getting the error message: Warning: include(inc/news.php?id=) [function.include]: failed to open stream: No error in C:\xampplite\htdocs\lukerodham\old\index.php on line 218 Warning: include() [function.include]: Failed opening 'inc/news.php?id=' for inclusion (include_path='.;C:\xampplite\php\PEAR') in C:\xampplite\htdocs\lukerodham\old\index.php on line 218 just wondering if anyone could shed any light on what i may have done wrong thanks guys ive left part of the code below if this will help. <?php $page = $_GET['page']; $news = $_GET['id']; if(!$page){ getnews(); } else { if($page = news){ include("inc/news.php?id=".$news); } else include("inc/".$page.".php"); } ?>
×
×
  • 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.