-
Posts
1,807 -
Joined
-
Last visited
Everything posted by hitman6003
-
What other text? The variable assignments aren't printed to the screen...the contents of the variable may/may not be echo'd or printed to the screen. I'm surprised that your sessions and redirect headers are working since there is data being sent to the browser before those are called.
-
Is this a functional way of exploding userID+update mysql DB CONCAT
hitman6003 replied to slyte33's topic in PHP Coding Help
It's always easier to store who has seen something like a thread than who hasn't. I've never looked at phpBB's code, but I would imagine they associate the user to the thread when it's been read. So, when I click on it, a row in a table is inserted that says "hitman6003 has read thread xyz at 0230GMT". -
Why wouldn't you change the text color using CSS? <style> body { color: #FFFFFF; }
-
Is this a functional way of exploding userID+update mysql DB CONCAT
hitman6003 replied to slyte33's topic in PHP Coding Help
meh... Are you hurting for space, than an extra MB or two (cause a row of 2 int columns doesn't take much room) is really gonna make a difference? Use an index and don't worry about it. Doing it the second way, if you wanted to query "Who's friends list is user 123 on?", you would have to query an expand everyone's list to get that information. -
StackOverflow's top voted php post is about SQL injection: http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php
- 14 replies
-
- sql
- sqlinjection
-
(and 3 more)
Tagged with:
-
Just sanitize your input. Check to make sure the user(s) provide input that is correct/valid and use the "real_escape_string" functions before doing inserts. http://php.net/mysql_real_escape_string http://php.net/mysqli.real_escape_string
- 14 replies
-
- sql
- sqlinjection
-
(and 3 more)
Tagged with:
-
use the DateTime object. $date = new DateTime($row['etd']); print $date->format('d-m-Y'); http://php.net/datetime.format Edited to change format from "Y-m-d" to "d-m-Y".
-
well...after further investigation, I appear to be wrong about that. I think the problem is that you are checking for "$_POST['submit']" to exist, but the image input type doesn't pass a value.
-
The HTML input tag does not have an image type that is also a submit button. http://www.w3schools.com/tags/tag_input.asp You could change the look of the button using CSS, or use javascript to submit the form when the image is clicked.
-
If they are on separate lines, use the explode function on the input... $songs = explode("\n", $_POST['songs']);Just make sure you sanitize the input before doing anything with it.
-
Real Escape String - can't get it to work
hitman6003 replied to rockonxox's topic in PHP Coding Help
Provide the connection variable with mysqli_real_escape_string.. mysqli_real_escape_string($con, $_POST['ecuid']) -
Help needed to make a login script redirect to another reserved page
hitman6003 replied to 3joez's topic in PHP Coding Help
if you start with the object style mysqli, you have to use it...can't switch between them...so your use of mysql_i_connect_error() won't ever return anything. Aside from that, add in some debug to check for expected results: <?php function login($username, $password) { $con = new mysqli("db_server.com", 'User', 'plain text password', 'whateverdb'); if ($con->connect_errno) { die($con->connect_error); } $pass = md5($password); $query = "SELECT * FROM user WHERE username = '$username' AND password = '$pass'"; if ($result = $mysqli->query($query)) { if ($result->num_rows > 0) { print "<pre>got the following results:\n\n"; while ($row = $result->fetch_assoc()) { print_r($row); } } else { print "no rows were returned!"; } } else { die($con->error); } } -
Help needed to make a login script redirect to another reserved page
hitman6003 replied to 3joez's topic in PHP Coding Help
You're still not using the mysqli object correctly...it has four options: hostname, username, password, database. http://php.net/mysqli.__construct mysql_error will not work when using mysqli...use mysqli->connect_error or mysqli_connect_error(). http://php.net/mysqli.connect_error You're using "mysql_query" instead of the mysqli object's "query" method. http://php.net/mysqli.query -
Help needed to make a login script redirect to another reserved page
hitman6003 replied to 3joez's topic in PHP Coding Help
If you are going to use it like that, you'll need to adopt the object oriented style... $con = new mysqli($host, $user, $pass, $database); $result = $con->query("SELECT something FROM somewhere"); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { echo $row['something'] . "\n"; } } -
Help needed to make a login script redirect to another reserved page
hitman6003 replied to 3joez's topic in PHP Coding Help
SocialCloud has the answer...use either mysql_* functions, or mysqli_* functions, don't mix them. -
Help needed to make a login script redirect to another reserved page
hitman6003 replied to 3joez's topic in PHP Coding Help
Add some debug output to your code and make sure that what you expect to happen is happening... <?php //at the start of each page have: start_session(); print "<pre>The contents of session are:\n" . print_r($_SESSION, 1); .... .... function login($username, $password){ print "\n At function login with username $username"; ......... if ($count==1) { print "\nThe user was found"; $_SESSION['login']=$username; // this won't work because we've already output something to the browser header('Location:Aggiornamenti/Aggiornamenti.php'); /*this doesn't actually work*/ } else { header('Location:index.php'); /*this doesn't actually work*/ echo "Wrong login"; } } -
Help needed to make a login script redirect to another reserved page
hitman6003 replied to 3joez's topic in PHP Coding Help
Not sure if it affects the header or not, but I've always used a space between the colon and the location. Also, use an exit after the location header to stop execution (otherwise the php will continue to execute, even though you are redirecting the user. header("Location: some/page.php"); exit;I *think* leaving off the exit, if there is code further down that sends something to the browser, it will cause the location redirect to fail. -
You only have one "=".... if($check_for_duped_person = "1")You need two "==" for comparison. The single "=" sets the value to 1.
-
Print out your query and make sure it is what you expect it to be: print '<pre>My query is:'; print " SELECT `id` FROM `delivery_information` WHERE `contact_name` = '$recipient_name' AND `post_code` = '$ship_postal_code'";
-
Also check out the natsort function. Alternatively, you could brute force it with some loops... foreach ($results as $result) { list($a, $b) = explode("/", $result); $data[$a][] = $b; } foreach (ksort($data) as $key => $values) { sort($values); foreach (sort($value) as $x) { print $key . "/" . $x; } }Not exactly elegant though.
-
Print out some error checking in your while loop... while ($x < 95) { ... print '<pre>'; ...... print '\nrow:\n' . print_r($row, 1); .... print "\n rowb: \n" . print_r($rowb, 1); .... print "\n Final insert query is: \n"; print $queryc
-
Reverse the options for mysql_query... mysql_query("SELECT * from sites", $connect);
-
Is any error output? Try adding some debug output...for example, check your $_POST and query: print '<pre>' . print_r($_POST, 1); print "my query is: INSERT INTO comments (id, userid, topicid, topicname, comment, date, name) VALUES ( '', '$_SESSION[id]', '$content[id]', '$content[name] Profile', '$_POST[comment]', '$today', '$_SESSION[username]' )"; Does it look like you expect it to?
-
You can either put them into a table instead of a div, or set the css for the div to "float: left;" Change: <div class="options"> to: <div class="options" style="float: left;"> And see if it does what you want.
-
Which line is 44?