Jump to content

hitman6003

Members
  • Posts

    1,807
  • Joined

  • Last visited

Everything posted by hitman6003

  1. 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.
  2. 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".
  3. Why wouldn't you change the text color using CSS? <style> body { color: #FFFFFF; }
  4. 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.
  5. StackOverflow's top voted php post is about SQL injection: http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php
  6. 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
  7. 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".
  8. 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.
  9. 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.
  10. 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.
  11. Provide the connection variable with mysqli_real_escape_string.. mysqli_real_escape_string($con, $_POST['ecuid'])
  12. 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); } }
  13. 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
  14. 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"; } }
  15. SocialCloud has the answer...use either mysql_* functions, or mysqli_* functions, don't mix them.
  16. 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"; } }
  17. 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.
  18. You only have one "=".... if($check_for_duped_person = "1")You need two "==" for comparison. The single "=" sets the value to 1.
  19. 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'";
  20. 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.
  21. 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
  22. Reverse the options for mysql_query... mysql_query("SELECT * from sites", $connect);
  23. 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?
  24. 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.
×
×
  • 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.