Jump to content

MrAdam

Members
  • Posts

    489
  • Joined

  • Last visited

Everything posted by MrAdam

  1. MrAdam

    phpmyadmin questions..

    okay .. "varchar" stands for variable character (I pressume) so any kind of text can go in there - for a description of each of them in the list, google "data types".The length field is the maximum length of characters to go in that field.. so if you had a field with the length "5", you could only fit 5 character sin the field (e.g. 'abcde').The default is what will be used if nothing is entered into the field. Default isn't required.-Adammm
  2. if you don't want it to give any output, just put: copy($file, 'images/users/' . $username . '/bg.jpg');
  3. I only ask because I've recently created a website that relies on javascript to submit a lot of forms and would like a rough figure...b but i do reckon most people who use this forum will have javascirpt enabled, so if you have any comments about it ........
  4. i once had this problem .. try this: function mouseXY(event) { mouseXY(event);
  5. document.getElementById(cel).style.visibility = 'visible'; .. try that
  6. MrAdam

    BBCodes

    look what else you can do with strip_tags() - http://uk.php.net/strip_tags - you can set what tags are allowed.
  7. EDIT: i thought you'd all missed "&quot" .. nevermind ! haha
  8. MrAdam

    BBCodes

    $tekst = strip_tags($tekst);
  9. MrAdam

    BBCodes

    use:strip_tags($str)
  10. MrAdam

    Login script

    try this instead:$query = mysql_query("insert into Admins (User,Pass,ID) values ('{$_POST['user']}','{$_POST['pass']}','{$_POST['2']}')"); .. you didn't close the function... and the code i gave you before I didn't test it so there could be an error or two. try this: $query = mysql_query("SELECT * FROM vytas_form WHERE User='{$_POST['username']}' AND Pass='{md5($_POST['password'])}'");
  11. it would all depend on where the image comes from, but if the user were to upload it as they register (?) you'd need to look into uploading images .. plenty of scripts/tutorials around.If you were copying the image from another location, you'd want to use something like: <?php $to_folder = "user_folder"; $file = "image.jpg"; if (!(copy($to_folder,$file))) { echo "Error copying file"; } else { echo "File successfully copied"; } ?>
  12. where will the ".jpg" image come from?but yes it's possible, when you create the folder, create some more code to add the jpg file aswell.
  13. Ahh I think I get you. I'd say you'll probably need to use "AJAX" / "JavaScript" to be able to get a row of data from the database without refreshing the page.w3schools.com has tutorials for both.
  14. MrAdam

    sha512

    well i think you'd need to use it with the "mhash()" function, an example of it using md5:mhash(MHASH_MD5, $str);i'm not sure if "sha512" is valid or not.. the mhash function doesn't come as a standard with PHP i believe, you have download it.
  15. in your query .. at the end you can put: "LIMIT 1, 1" .. the first '1' is where to start from.. and the second is how many to display.. so:LIMIT 1, 1 = first rowLIMIT 2, 1 = second rowLIMIT 3, 1 = third rowetc..example in a MySQL query: SELECT * FROM table LIMIT 1, 1
  16. MrAdam

    Hey!

    strlen($var); .. perhaps ?
  17. MrAdam

    Removing 0's

    thanks but that didn't help ..UPDATE: sorry, was using it wrong .. number_format($price, 2); works great thanks!
  18. MrAdam

    Login script

    you got the basic idea.. but you don't seem to understand parts of it... if ($_POST['user']==mysql_query("select User from Admins")){echo "u have been succesfully logged in";} You don't seem to be using POST right. If you are wanting to send the sql string in the POST method (which i wouldn't recommend - big security risk!) you would have to send just the string and not "mysql_query(..)" - then run the sql after returning the string.But, i don't think that's what you are trying to do .. i'd use: // include all your connection code$query = mysql_query("SELECT * FROM vytas_form WHERE User = '{$_POST['username']}' AND Pass = '{md5($_POST['password'])}'");if ($query) { $_SESSION['username'] = $_POST['username']; $_SESSION['password'] = md5($_POST['password']); print "You have been logged in...";} else { print "Your username or password are wrong...";} Broken down:The first 2 lines are to query the database, the sql string means: "select everything from the vytas_form table where the 'User' field and the 'Pass' field are equal to the values the user entered." The md5() function calculate the md5 hash of a string - an irreversible code basically.The next part is an 'if' to check if the query was successful. IF it was, the username is stored within a session - for future use - and some information printed to the user and now the user is effectively "logged in". IF the query was unsuccessful, this means the user does not exist in the database and so an error message is printed to the user.To use this script, you'll need to create a login form with the inputs named "username" and "password" - though you can change the POST name ($_POST['__name__'] ) within the script.
  19. MrAdam

    Removing 0's

    Hi. i have made a shopping cart and all works perfectly apart from when adding the items, the sub totals have 0's removed off the end. How do i prevent PHP from automatically removing the 0's ?
  20. google "php script + download files" or something, there'll be plenty available.
  21. $handle = fopen('the_file.txt', 'r');if ($handle) {$contents = stream_get_contents($handle);print $contents;fclose($handle);} else {print 'Error reading file.';}
  22. i'd reccomend saving the file in .txt files or .tpl files and then only saving the filename and id in the database. <?phperror_reporting(E_ERROR);// get file from database using id$handle = fopen('_file_', 'r');if ($handle) { $contents = stream_get_contents($handle); print $contents; fclose($handle);} else { print 'Error reading file.';}?> ...you'll need to add some code to find the corresponding file to the id.
  23. thankyou - makes a lot of sense.
  24. MrAdam

    Possible?

    will it be like a chatroom ? or will they be refreshing the page often (like a regular website)?
×
×
  • Create New...