
Wolphie
Members-
Posts
682 -
Joined
-
Last visited
Never
Everything posted by Wolphie
-
calling mysql_query fron inside a function
Wolphie replied to HaLo2FrEeEk's topic in PHP Coding Help
Why not put your queries inside an associative array and then run the mysql_function() on a specific query inside the script that it should be ran? -
Yes, but before using stripslashes() you should really check if it's necessary. If magic_quotes_gpc() isn't enabled, then it isn't necessary to use.
-
It has no advantages OVER mysql_real_escape_string() but it does help, depending on what you're trying to achieve. mysql_real_escape_string() calls MySQL's library function mysql_real_escape_string, which prepends backslashes to the following characters: \x00, \n, \r, \, ', " and \x1a. mysql_real_escape_string() prevents SQL-Injections, however, things such as htmlspecialchars() can help prevent Cross-site scripting. Do you see the difference?
-
help calling some information from a session
Wolphie replied to jacko_162's topic in PHP Coding Help
Why not just use $_SESSION['SESS_MEMBER_ID'] to insert it into the table? However // Will give $member_id the value of $_SESSION['SESS_MEMBER_ID']; $member_id = $_SESSION['SESS_MEMBER_ID']; -
help calling some information from a session
Wolphie replied to jacko_162's topic in PHP Coding Help
Do you have session_start(); at the very top of your script? What are the errors being thrown? -
Well, the only simplified way I know is using two queries. If you already have the ID of the current record, you can select the next biggest record. <?php // Select the next biggest record and limit it by 1 so only that record is returned $sql = "SELECT * FROM some_tbl WHERE id > $current_id LIMIT 1"; $result = mysql_query($sql); if (mysql_num_rows($result) > 0) { $nextid = mysql_result($result, 0); } ?> To select the previous one it's the reverse, so instead you find the lowest using $sql = "SELECT * FROM some_tbl WHERE id < $current_id LIMIT 1"; Bear in mind that code is just an example, all of the variables used within the query should be sanitised and validated accordingly.
-
http://www.php.net/manual/en/function.ftp-chdir.php
-
Also, please use the code BBCode tags when posting code.
-
Use stripslashes() before inserting the text into the e-mail body/subject field. http://php.net/manual/en/function.stripslashes.php
-
Change the mode to FTP_BINARY and try again.
-
You can only check to see if it's hidden in JavaScript. It isn't possible with PHP.
-
Users photo gallery with default picture for their profile
Wolphie replied to TeddyKiller's topic in PHP Coding Help
Yes it is possible, just change the permissions of the folder. -
I wouldn't know how to go about creating a proxy script, however 'glype' is supposed to be a good proxy script to use, written in PHP. http://www.glype.com/downloads
-
Users photo gallery with default picture for their profile
Wolphie replied to TeddyKiller's topic in PHP Coding Help
Sorry, I'll be more specific. Let's say you have 2 database tables, one named users and the other named images. Each user would be given a unique ID when they register, and the user table would contain this unique ID and all of their profile information. The images table would also contain a unique image ID, and ALSO a user ID field (which isn't a primary key), so that when a user uploads an image, that image is given a unique ID and the ID of the user is also inserted for that particular image(s). This is known as a relational database. In the images table, you would also have information such as file name, file type, file size and the path to the file. In the users table you would have something like avatar_id which would correspond to the image ID they selected from the images table. You can then select this record and all of the information with it, including the path which will allow you to display it on screen. -
You could try UPDATE table_temp SET sum = table_temp.Point - (SELECT Point FROM table_RATING)
-
Users photo gallery with default picture for their profile
Wolphie replied to TeddyKiller's topic in PHP Coding Help
Well to begin with you'd require a user to create a new account, once this has been done you should be storing information specific to them in the database. Once this data is in the database it can now be used to construct a profile specific to each user. Each user should have a unique ID to identify them amongst other users (important for profiles, e.g. http://somesite.com/profile.php?id=54, 54 being the ID of the user). This link would then take them or another person to their profile page that contains information specific to them. If it is their page, then you should have some kind of administration facility where users can upload files (you're after just image files, example code can be found here: http://www.w3schools.com/PHP/php_file_upload.asp). Once one or more images have been uploaded, given a unique ID along with the ID of the user who uploaded them, you can now proceed to turn it into a gallery (http://somesite.com/gallery.php?id=54, again 54 being the ID of the user). When you create the gallery script you can pull images from the database specific to that user (i.e. the ones that user has uploaded). With this in mind you can add radio buttons for each image, giving the radio buttons the same IDs as you gave each individual image. This will allow you to submit a form with the selected radio button so you can then change the users default picture in the database by pulling only that image. Pulling random users from the database is quite simple, use the MySQL RAND() function and LIMIT clause to pull a random number of records (users) and display any relevant information about them that you see fit. -
Well, first off if you're working with integers you shouldn't be quoting them. <?php $number = 1; if ($number != 1 || $number != 2) { echo "hello"; } ?> Secondly, you're using an OR operator (||), this means that if it doesn't equal 1 OR 2 then display "hello". Well, it doesn't equal 2, so the expected result is correct. <?php $number = 1; if ($number != 1 && $number != 2) { echo "hello"; } ?> You want to use the AND operator (&&) for your expected result.
-
How is this possible? Textarea is ending entire session.
Wolphie replied to slyte33's topic in PHP Coding Help
Also bear in mind that array keys should be surrounded in quotes and not implicitly included within a string. E.g. You've used: echo "<form action=forums.php?$gid&id=$_GET[id]&topicid=$_GET[topicid] method=post>" When in fact it should be: echo "<form action=\"forums.php?$gid&id=". $_GET['id'] ."&topicid=". $_GET['topicid'] ."\" method=post>" -
Put this at the top of your update script: <?php mysql_query(sprintf("UPDATE sometable SET column1 = %d", time())); ?> Every time the update script is ran, it'll update a specific column in a specific table with the current time the script was ran.
-
You should be absolutely fine to do this, sounds like a reasonable solution.
-
Then there's a problem with your error handling in your code, rather than a server issue. Also, bear in mind that it won't work if you concatenate all of the elements into a single string. $img1_name = $_FILES['img1_name']['name']; // This must remain just for the name, not size etc..
-
Try setting up some error handling, add a var_dump() or a die() somewhere in the script to see where it's failing.
-
Please bear in mind that $_FILES is a multi-dimensional array. http://www.w3schools.com/PHP/php_file_upload.asp $_FILES['img1_name']['size'] $_FILES['img1_name']['name'] $_FILES['img1_name']['type'] $_FILES['img1_name']['tmp_name'] $_FILES['img1_name']['error'] etc... I can't see anywhere in your code where you use these.
-
text inputs are being changed to some sort of weird text.
Wolphie replied to jamesxg1's topic in PHP Coding Help
Check the encoding of your database. It should be utf8.