Jump to content

phpBeginner06

Members
  • Posts

    93
  • Joined

  • Last visited

    Never

Everything posted by phpBeginner06

  1. genericnumber1, That will not work for me; I do not have apache. Any other ideas? - Thanks
  2. Does any one know how to add a php echo or print to a form field that is in an external javascript? I have an external JS with a function that populates a DIV via innerHTML. It places a form in the DIV, through innerHTML. I want to be able to put this in a form field in my external javascript: <? echo "$Name"; ?> and when the function fires; the innerHTML would insert the form in the DIV and the php echo/print would display in the form field. But when I use the above code in my form field of my external javascript; it just inserts the value as text, not actual php code. Any one know how to do this?
  3. I have a form that is sent to php page with code to send an email. I set this php page to check for the prevoius form for required fields. If the form fields are not correct; the php email code is set up to send a javascript function (ie "csError()") back to the form page through posting a querying string. What I would like to do is destory the this query string once the form page reloads or unloads. I read a little bit about the unset[$_POST()] function; but I cannot make it work the way I would like it to. Here is how my form page body onload event is set-up: <body onload="<? echo "$issue"; ?>"> I also read a little bit in the PHP Manual about "msg_remove_queue"; but I could not find any documention example on how to use that function. Does anyone know what the best way too use "unset" or "msg_remove_queue" (without using sessions - I have not learned how to use sessions yet) to remove my posted query sting from my onload event; once my form page is reloaded?
  4. Is there a way to use number_format() with a PHP Include that is a text file? I made a script, but it does not echo that right results. [code]<?php $somenumber=include("01-25-2007.txt"); $formatted=number_format($somenumber); echo "$formatted"; ?>[/code] The text file "01-25-2007.txt" contains the number "1000". The script should echo a number like "1,000"; but instead it's echo looks like this: "10001". Is it even possible to use number_format() with a text inlude? If so, what is the best way to go about doing it?
  5. Is there any way to use commas with "somevalue=somevalue + 1" once it starts counting into the thousands. I was looking in one my mysql book and have not found it used there; I have not referenced it in my PHP book yet. But I was thinking there was some way it could be done with mysql; not sure though. For example if I keep inserting "somevalue=somevalue + 1" and get up 999; my next "somevalue + 1" will then put me into the thousands. So it would display "1000" and I would like to find a way to display "1,000" (with comma separators for thousandth). Any one know how I might do this with MySQL/PHP or is this a JavaScript resolution?
  6. [color=blue]Thank You Thorpe that worked out just the way I wanted it to.[/color]
  7. I am trying to automatically insert a new row into data table; if there is no row with specific field value. But the code I have written below is not doing anything at all. Where Am I Going Wrong With This Code? [code]<?php mysql_connect("localhost","username","password"); mysql_select_db("Statistics"); $page = $_SERVER['PHP_SELF']; $look4 = "SELECT * FROM hitsTable WHERE page = '$page'"; $check = mysql_query($look4); if(mysql_num_rows($check) == 0){ mysql_query("INSERT INTO `hitsTable` (visits, page) VALUES ('1', '$page')"); }else { echo "logged"; } } ?>[/code]
  8. That worked out great - Thank You Very Much - Just one question; what is the "0" for in the "$r[0]" ???
  9. Ok - I tried that; but now it is not printing anything. Here is my code below: [code]<? print "<table><tr><td>"; mysql_connect("localhost","username","password"); mysql_select_db("Statistics"); $addUp = mysql_query("SELECT SUM(visits) FROM hitsTable"); while($r=mysql_fetch_array($addUp)) { $addUp=$r["visits"]; print "$addUp"; } print "</td><td>Total Hits</td></tr></table></center>\n"; ?> [/code]
  10. I am trying to add up all the numbers in one column of my data table. The column name is "visits" and the data table is named "hitsTable". Here is my code: [code]$addUp = mysql_query("SELECT SUM(visits) FROM hitsTable"); print "$addUp";[/code] When it prints; I get this: [quote]Resource id #4[/quote] What is this and why is it not adding up my column?
  11. matto, i figured it out, but i went a different route - but [u][b][color=red]!!! THANK YOU !!![/color][/b][/u] for all your help. Below is the link to the final working script: [url=http://www.phpfreaks.com/forums/index.php/topic,123428.0.html#msg511224]http://www.phpfreaks.com/forums/index.php/topic,123428.0.html#msg511224[/url]
  12. To everyone that helped me with this code; let me say [u][b][color=red]!!! THANK YOU !!![/color][/b][/u]. I finally got it to work the way that it is supposed to work and I am extremely happy about that. [u]MySQL Database & Data Table Script[/u] [code] CREATE DATABASE `Statistics` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci; USE Statistics; CREATE TABLE `hitsTable` (   `visits` text NOT NULL,   `page` text NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; INSERT INTO `hitsTable` VALUES ('0', '/Sub-Directory-Name-Here/01-23-2007.php'); [/code] [u]PHP Hit Counter Script[/u] [code] <?php if (empty ($_COOKIE['visit'])) { mysql_connect("localhost","username","password"); mysql_select_db("Statistics"); $page = $_SERVER['PHP_SELF']; mysql_query("UPDATE hitsTable SET visits=visits+1 WHERE page='$page'"); setcookie ('visit', 1, time()+86400); } ?> [/code]
  13. linuxdream, I tried it like you said to (similar atleast) and the cookie works, but it still is not sending the variables to the database. I created a new table and used your script (similar atleast); below is the code. [u]MySQL Data Table[/u] [code]CREATE TABLE `hitsTable` (   `visits` text NOT NULL,   `page` text NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1;[/code] [u]PHP[/u] [code]<?php if (empty ($_COOKIE['visit'])) { mysql_connect("localhost","username","password"); mysql_select_db("Statistics"); $page = $_SERVER['PHP_SELF']; mysql_query('UPDATE hitsTable SET visits = visits + 1 where page = "$page" LIMIT 1'); setcookie ('visit', 1, time()+86400); } ?>[/code] So what am I still doing wrong; why will it not post to database?
  14. That is the problem. I do not know code I need to use for the get_new_user() function or for the record_hit() function. any ideas.......
  15. businessman332211, The problem with an IP Address is that it's more likely to change before a cookie is to be erased. I have a script I found on another page, but I do not know what the code would be that I need in a function for: "get_new_user" or "record_hit". Here is the script below: [u]Data Table MySQL Code[/u] [code]CREATE TABLE ur_hits (   page VARCHAR(30) NOT NULL,   ref VARCHAR(40) NOT NULL,   user_id INT UNSIGNED,   counter INT UNSIGNED,   PRIMARY KEY (page, user_id)   );[/code] [u]PHP Code[/u] [code]<? $db=mysql_connect("localhost","username","password"); mysql_select_db("Statistics",$db); if (!isset($user_id)) {   $user_id=get_new_user();   setcookie ("user_id", $user_id, time()+315360000, "", "http://www.mydomain.com, 0);   } record_hit($user_id, $PHP_SELF); mysql_query("UPDATE ur_hits SET counter=counter+1 WHERE page = '$PHP_SELF' AND user_id=\"$user_id\" ",$db); ?> <html> <head>         <title>Untitled</title> </head> <body> </body> </html> [/code] [color=blue]Does anyone know what function I need to create for "get_new_user" and "record_hit" ???[/color]
  16. linuxdream, This would work great for page views, but there is no way of knowing if this is a unique visitor with this script. I want to be able to set a cookie when a page is veiwed for the first time and send a "count + 1" to a specific field within a database datatable. If a person with my cookie (set from the prevoius visit) visites this web page again; the MySQL UPDATE count + 1 would not occur. Otherwise if my cookie is not set; MySQL would UPDATE the count of the datafield (ie count + 1). Say this field was called "Visits" and each time a new visitor (one without my cookie) views this page for the first time; the datatable field will count + 1 or count ++ (not sure if that is proper syntax or not - ie count + 1 or count ++). This will the datatable will look like this: Visits Page   4    http://www.domain.com   3    http://www.domain.com/page1   2  http://www.domain.com/page2 and not like this Visits Page   1  http://www.domain.com   1  http://www.domain.com   1  http://www.domain.com   1  http://www.domain.com   1  http://www.domain.com/page1   1  http://www.domain.com/page1   1  http://www.domain.com/page1   1  http://www.domain.com/page1   1  http://www.domain.com/page2   1  http://www.domain.com/page2 I want a single data field to be updated by 1 visit for every non-cookied visit (ie new visitor). There must be a way to do this with a database MySQL_Query UPDATE and cookies. I know it is possible with a text file and cookies.
  17. OK - so I posted a hit counter script on this forum and never could it to work; so now I am asking you guys how you would do this. How would I go about creating a unique hit counter based on cookies; that will post a unique visit to database: ie. Visits  Page   26      http://www.domain.com   38      http://www.domain.com/page1   19      http://www.domain.com/page2 I need to know like, what the MySQL table structure would look like and what the php code would be. I know this is asking alot, but right now I have a script that only record unique hits to a text file (cookie based). I want to record every unique hit to a database; that way I can display all my results in a web page using a MySQL Query (so I do not have to use "hard" html coding and php includes to display the number of page hits).
  18. Matto, Its in there; look at the code again - it is registered in a variable and the variable in the script is below. [code]"$user_id=get_new_user();"[/code]
  19. It must not be making it to that section; because it will not echo anything before mysql_query. Why would it not be making it to this section; does anyone know? As a reference to this script that I found; here is the link below. Maybe I just am not coding it right; like the script shows how too, but it seems like I am (I don't know). [url=http://trkwebhosting.com/modules/free-php-hit-counter-script.php]http://trkwebhosting.com/modules/free-php-hit-counter-script.php[/url]
  20. I just used this script: [code] <? phpInfo; ?> [/code] and I found that the register_globals is "on". So does anyone have any idea why script will not work; since register_globals is set to "on"?
  21. The script you provide did not give any type of results; it was just a blank page. Which PHP Configuration file do I need to open too make sure register_globals set to "on"? If I set it to "on" will my script work? PS: I have MySQL 4.1.14 ruuning on my server; will the script I am using work with this version? Do I need a updated version of MySQL for my script to work; could that be the problem?
  22. I am trying to create a unique hit counter with the script below (that I found on another website). I can get the script to set the cookie, but it will not send mysql_query UPDATE to the "ur_hits" data table; if the cookie does not exist (like the script should be doing). [u]Data Table[/u] [code] CREATE TABLE ur_hits (   page VARCHAR(30) NOT NULL,   ref VARCHAR(40) NOT NULL,   user_id INT UNSIGNED,   counter INT UNSIGNED,   PRIMARY KEY (page, user_id)   ); [/code] [u]PHP Hit Counter & HTML Code[/u] [code] <? $db=mysql_connect("localhost","username","password"); mysql_select_db("Statistics",$db); if (!isset($user_id)) {   $user_id=get_new_user();   setcookie ("user_id", $user_id, time()+315360000, "", "http://www.mydomain.com, 0);   } record_hit($user_id, $PHP_SELF); mysql_query("UPDATE ur_hits SET counter=counter+1 WHERE page = '$PHP_SELF' AND user_id=\"$user_id\" ",$db); ?> <html> <head>         <title>Untitled</title> </head> <body> </body> </html> [/code] Does any one know what I am doing wrong? If so, how can I fix it and/or get this unique hit counter to work?
  23. Thanks For Your Help "michaellunsford" and "JJohnsenDK", but since I last posted this script; I found another script, on another website. The script I just found on this other website has a multi-upload option, but does not have "allowed file type" security in the script. That's ok with me, I already know who is uploading these files with this file upload script (me!!!). So I know what files I will allow myself to upload - LOL!!! Just in case someone else is looking for a script like this; visit this webpage below. It worked out really good for me and maybe it will for you too. [url=http://www.plus2net.com/php_tutorial/php_multi_file_upload.php]http://www.plus2net.com/php_tutorial/php_multi_file_upload.php[/url]
×
×
  • 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.