Jump to content

mosi

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Everything posted by mosi

  1. try using this: DB_SERVER - localhost DB_NAME - blyz07_dbtables
  2. You use method:POST in your form: <form action="phptest.php" method="post"> But in later on you use $_GET. Either change method to GET or change your $_GET's to $_POST
  3. Not sure if this is better in mysql or here, but I figured here in the end. I have two tables: Calendar -day -month -year -contentID Read -contentID -userID When a user is logged in I have the calendar check all days for the current month thats showing. This then links to the conentID in the database for that day. What I want is to be able to combine this with the Read table so that if a user has already read that contentID then it wont link or show it not in bold or something. I current have it so that when a user reads that contentID it adds the current userID and contentID to the Read table. The problem I'm having is how I can easily check if a user has read a certain contentID without running a mysql query everytime the calendar's while loop goes round to get calendar data just to check if the row exists. Can I do a JOIN somehow even when the 2nd table may not contain any data to join it with? What I want to be able to do from this is allow me to colour the calendar cells a different colour if the user has read a contentID already. Hope all that makes sense
  4. Just a quick question. If I have an if statement which goes "if ((a == b) && (c==d) && (e==f))" if a != b does it still check the other two parts to the statement or not? I know it won't really make much difference if any to load times but I was just curious.
  5. I'm guessing he means when creating a new post for example on these forums you get the smiley buttons above the textbox to type your post. Then if you click a smiley it inserts code for that in the textbox for you. Not sure of a way to do it exactly becuase I'm tired but I think it's all done with javascript, you could prolly find something from the source of the new post page Just wanted to post to hopefully make your question clearer.
  6. Just to add, I'm another one who prefers int(11) with unix time stamps, I find it easier to sort and use for some other scripts I use.
  7. <?php $original_text = "this is the original text"; $original_text = str_replace("original", "new", $original_text); echo $original_text; // Will echo "this is the new text" ?> Look at: http://www.php.net/str_replace for more information
  8. You set your variables using $_GET['x']; here: $costpermonth = $_GET[cpm]; $renewalday = $_GET[rday]; $renewalmonth = $_GET[rmonth]; $renewalyear = $_GET[ryear]; When your form for submitting uses POST, try changing them to: $costpermonth = $_POST[cpm]; $renewalday = $_POST[rday]; $renewalmonth = $_POST[rmonth]; $renewalyear = $_POST[ryear]; Also to tidy your code a bit, at the end use: if (isset($_POST["calculate"])) { echo "The total price is $totalprice<BR>"; echo "The price without VAT is $price<BR>"; echo "The VAT is $VAT<BR>"; } Any better now?
  9. To get the visitors ip it's this bit of code: $_SERVER[REMOTE_ADDR] When a user is logged in do you set cookies or a session variable at all with the userid or something like that so you can use: "or userid = '$_SESSION[userid] ";" at the end of the select statement. I have also added "userid = '$_SESSION[userid]' ";" to store the userid in the table (you would have to add a new column for this in the db) Set the itemid, userid, ip as primary on your db and use REPLACE INTO instead of INSERT INTO too. <?php require_once("conn.php"); //check the user $q1 = "select * from dd_rating where ItemID = '$_POST[itemID]' and ip = '$_SERVER[REMOTE_ADDR]' or userid = '$_SESSION[userid]' "; $r1 = mysql_query($q1) or die(mysql_error()); if(mysql_num_rows($r1) == '0') { $q2 = "REPLACE into dd_rating set ItemID = '$_POST[itemID]', Rating = '$_POST[rr]', ip = '$_SERVER[REMOTE_ADDR]' , userid = '$_SESSION[userid]' "; mysql_query($q2) or die(mysql_error()); header("location:$_SERVER[HTTP_REFERER]&rate_error=n"); } else { header("location:$_SERVER[HTTP_REFERER]&rate_error=y"); } ?>
  10. How about set a column in the users table called pid, set it to int and set it to auto increment? That would keep it unique and auto generate it for you each time you add a new row to the table.
  11. In that case store the memberid or username instead of the IP and check for that instead. Or have both so: $q1 = "select * from dd_rating where ItemID = '$_POST[itemID]' and ip = '$_SERVER[REMOTE_ADDR]' or userid = '$userid' ";
  12. Basically it opens the file first for reading and stores the entire file as a variable called $current_data here: $current_data = @fread($file, filesize($newsfile)); so comment out that line then change: if(fwrite($file,$btable . " " . $btitle . " " . $_REQUEST["title"] . " " . $etitle . " " . $bdate . " " . $_REQUEST["date"] . " " . $edate . " " . $bpost . " " . $_REQUEST["post"] . " " . $epost . " " . $etable . "\n " . $current_data)) to: if(fwrite($file,$btable . " " . $btitle . " " . $_REQUEST["title"] . " " . $etitle . " " . $bdate . " " . $_REQUEST["date"] . " " . $edate . " " . $bpost . " " . $_REQUEST["post"] . " " . $epost . " " . $etable . "\n ")) The original code inserts the new news then adds $current_data onto the end so the news is posted with newest first. Hope this helps.
  13. One thing I noticed in your variables, your missing a ; at the end of: $cpgdb_prefix = "freeclip_"
  14. Just had a very quick search for free hosting with php and mysql - http://www.tripod.lycos.co.uk/ is one.
  15. Alright, cheers guys. I'm off home from work now so I'll give it a go later. Was affraid it may be too much data for it to handle but its on a dedicated server atm which is hardly being used so I don't know why I'm worried really. Will post back later with some results if I get chance. thanks for the help. Supprised I have never been here before, think I'll stick around adn try and help out
  16. If I did this, would it not generate a HUGE amount of data in the database? I have 5000 archived comics (ish) right now, say I have 10 users... that would be 50000 entries. 100 users... 500000 entries. That was the problem I was thinking with my original idea of just having a table with userid, comicid, archiveid. and using REPLACE INTO or something when a comic is read then check with the calendar if the row exists with data userId,ComicId,ArchiveID. So the question really now.. Would that much data in the database be a problem? Every time a new user signs up this would have to add a new table with all the current comic entries in it.
  17. Where are you getting $a1[did] from? Can you post the function which provides this variable please? In your second post you have $a1 but it is declared after the <script>. It will need to be before if thats what is declaring it.
  18. I have a table for each comic called archive_<comic_name> In that table I have: ID - auto increment ArchiveID - unixtime of the archived comic, i use this for next / previous buttons under each comic comicurl - the url to the archived comic day - used for the calendar month - used for the calendar year - used for the calendar As you can guess 1 row per archvied comic strip. I also have another table called comics which stores the ComicID and other info about each comic. This info only changes when a new comic is added (new comic, not archive) Users do not have to login to view the comics no. Right now being regged only gives you access to rating comics, creating a favorites list.
  19. I have a script I'm writing which archives comics. I am trying to think of a way to allow users to be able to see which comics they havn't yet read. My script checks various comic sites throughout the day to check for new comics and if there is a new one it will store it. At first I want to make it so it will mark new comics since last visit, then I put a calendar up for each comic which will list each archived comic. I want to be able to make the calendar show up unread comics for the user. the problem I'm having is thinking of the best way to store the read/unread comics. Right now the database has around 5000 archived comics, and it will grow. Do you think it would be alright doing it this way to show all indevidual unread comics (ill provide and option to "mark all comics as read". Or would it be better to show in the comic list "new since last visit". If I did new since last visit and a reader was going through the archive then just left and came back later hoping to continue the reader would have to remember what comic they were at. Does anyone else have any ideas how I can do this?
  20. well in your example you set $sitelink then when you refer to it as $site_link. That might just be a typo for this post, but might not be. I know I've spent ages before because of something like that :/ I use the str_replace for someone similar for some of my code /* $row2["c_url2"] is a result from a mysql query example output is "http://example.com/archive/#yyyy#" where I want "http://example.com/archive/2007" */ $row2["c_url2"] = str_replace("#yyyy#",date('Y'),$row2["c_url2"]); echo $row2["c_url2"]; What errors are you getting from your code?
×
×
  • 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.