Jump to content

pixy

Members
  • Posts

    295
  • Joined

  • Last visited

    Never

Everything posted by pixy

  1. The point is, my way is beterrrrrrrrrr. :D
  2. [code]<?php echo '<a href="aim:GoIM?screenname=myscreenname"> <img src="http://api.oscar.aol.com/SOA/key=fl1aQV3Tmy/presence/myscreennameagain" border="0"></a>'; ?>[/code] There is no unescaped characters in that code above.
  3. This wont give a nice message to the user, but place a UNIQUE index on the series_title column. That way it wont let duplicates be entered.
  4. [code]<?php echo '<a href="aim:GoIM?screenname=myscreenname"> <img src="http://api.oscar.aol.com/SOA/key=fl1aQV3Tmy/presence/myscreennameagain" border="0"/></a>'; ?>[/code]
  5. Use this: (I accidently made it so that if $point wasn't equal to zero, it tells you "not enough", instead of if it was equal to zero. [code] <?php if ($_SESSION['paid'] != 'yes'){     if ($points == 0) {         exit('You do not have enough points.');     }     else {         $query = "UPDATE table SET points='$points' WHERE username='$Myusername'";         $result = mysql_query($query);         if (!$result) {             die(mysql_error());         }         $new_query = "UPDATE table SET paid='yes' WHERE username='$Myusername'";         $new_result = mysql_query($new_result);         if (!$new_result) {             die(mysql_error());         }     } } ?> [/code]
  6. So what error are you getting exactly? Is it not sending, wrong formatting...? You need to be more specific. :)
  7. You can use the function nl2br() to make new lines into the <br /> tag.
  8. Try replacing the part of your script with this... [code]<?php $sql = "SELECT count(p2) FROM datos"; $total = mysql_query($sql); if (mysql_num_rows($total) > 0) {     $row = mysql_fetch_array($total, MYSQL_NUM);     echo $row[0]; } else {     echo 'There are no records to count.'; } ?> [/code]
  9. Patience is a virtue, young grasshopper. Try this... [code] <?php if ($_SESSION['paid'] != 'yes'){     if ($points != 0) {         exit('You do not have enough points.');     }     else {         $query = "UPDATE table SET points='$points' WHERE username='$Myusername'";         $result = mysql_query($query);         if (!$result) {             die(mysql_error());         }         $new_query = "UPDATE table SET paid='yes' WHERE username='$Myusername'";         $new_result = mysql_query($new_result);         if (!$new_result) {             die(mysql_error());         }     } } ?>[/code]
  10. AUTO_INCREMENT is the best, as fenway said, for ids.
  11. [code] <?php $query = "SELECT email FROM b_users WHERE username='$user'"; $result = mysql_query($query); if (mysql_num_rows($result) == 1) {     $row = mysql_fetch_array($result, MYSQL_NUM);     $email = $row[0];     echo '<b>Your Email:</b> <input type="text" name="email" size="15" value="'.$email.'"><p>'; } else {     echo 'You do not have an email address saved in our database.'; } ?>[/code]
  12. pixy

    Sessions

    I think there's a way to store sessions on the server, but the "point" is the store them on the user's computer so it remember's their information. The tutorial posted is really the only way to do it. You detect the session information from the user and put it in the table and show if they've been active in X amount of time.
  13. ^ That already got closed, but you couldn't see it in the screenshots.
  14. And don't people with dialup get new IP addresses all the time?
  15. So the rest of the page doesn't load.
  16. [quote author=AndyB link=topic=100692.msg397800#msg397800 date=1152986709] if ($query) will always be true since you just defined $query.  I suspect you want to change that to if ($result). What's useful for debugging is to change $result = mysql_query($query); to: [code]$result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query);[/code] [/quote] Oops, that was totally a typo. XD Thanks so much for pointing it out. And thanks to Drumminxx, because I've gotta fix that too--it would spit out an error at me if I didn't change it. EDIT: It works now. Thanks so much!<33
  17. Couldn't you just use include("page.php"); or redirect them to page.php with header("location: page.php"); (but remember rules for sending headers so you don't get errors). Or, use this function for redirecting: <?php DEFINE("X_REDIRECT_HEADER", 1); DEFINE("X_REDIRECT_JS", 2); function redirect($path, $timeout=2, $type=X_REDIRECT_HEADER) {     // split session attack code fix     if (strpos(urldecode($path), "\n") !== false || strpos(urldecode($path), "\r") !== false)     {         error('Tried to redirect to potentially insecure url.');     }     // force session to be written before redirecting     session_write_close();     $type = (headers_sent() || $type == X_REDIRECT_JS ) ? X_REDIRECT_JS : X_REDIRECT_HEADER;     if ($type == X_REDIRECT_JS) {         ?>         <script language="javascript" type="text/javascript">         function redirect() {             window.location.replace("<?php echo $path?>");         }         setTimeout("redirect();", <?php echo ($timeout*1000)?>);         </script>         <?php     } else {         if ( $timeout == 0) {             header("Location: $path");         } else {             header("Refresh: $timeout; URL=./$path");         }     }     return true; } ?> And then, when you want to redirect do something like: redirect("page.php", 0); 0 is the time, so adjust it higher if you want it to linger one the results page before redirecting.
  18. Do you mean like where people are adding sentances to one single message that appears on the bottom... I can make one really easy, if that's what you're talking about. Do you have a database this can be stored in?
  19. I'm pretty sure you can change the maximum upload size in php.ini. It think it's set to like 8MB default.
  20. pixy

    SQL help

    Lol, that [i]might[/i] cause a problem. Glad you got it worked out.
  21. pixy

    SQL help

    Oops, I'm stupid. I used mysql_fetch_row() instead of mysql_fetch_array(). I never use the first function, so I have no idea how it came into my head...oh, that's because it's what you were using. That was probably your problem. Try this: [code] <?php $result = mysql_query("SELECT id, user, rank, rep FROM accounts ORDER BY id ASC"); while ($data = mysql_fetch_array($result, MYSQL_NUM)) {     echo '<tr>     <td width="25%" align="center" height="20">     <font face="Verdana" size="1" color="#54A800">'.$data[1].'</font></td>     <td width="25%" align="center" height="20">     <font face="Verdana" size="1" color="#54A800">'.$data[2].'</font></td>     <td width="25%" align="center" height="20">     <font face="Verdana" size="1" color="#54A800">'.$data[3].'</font></td>     <td width="25%" align="center" height="20">     <font size="1" face="Verdana" color="#54A800">[ <a href="contact.php?id='.$data[0].'">PM</a> ]</font></td>   </tr>'; } ?> [/code]
  22. pixy

    SQL help

    Try miiiiiiiiiine. :) Dude, you don't use { } when dealing with single quotes.
  23. pixy

    SQL help

    Try this: [code] <?php $result = mysql_query("SELECT id, user, rank, rep FROM accounts ORDER BY id ASC"); while ($data = mysql_fetch_row($result, MYSQL_NUM)) {     echo '<tr>     <td width="25%" align="center" height="20">     <font face="Verdana" size="1" color="#54A800">'.$data[1].'</font></td>     <td width="25%" align="center" height="20">     <font face="Verdana" size="1" color="#54A800">'.$data[2].'</font></td>     <td width="25%" align="center" height="20">     <font face="Verdana" size="1" color="#54A800">'.$data[3].'</font></td>     <td width="25%" align="center" height="20">     <font size="1" face="Verdana" color="#54A800">[ <a href="contact.php?id='.$data[0].'">PM</a> ]</font></td>   </tr>'; } ?>[/code]
  24. Yes, you must. http://www.google.com/search?hl=en&q=free+mail+server There are plenty to pick from.
  25. Okay, so I'm writing my own, simple forum script. It tells me the query was sucessful, BUT nothing is inserted into the database... Here's a screenshot of my posts table. (if there is an easier was to do this kind of thing, PLEASE tell me...I'm a bit "in the dark")... [img]http://img.photobucket.com/albums/v72/vanillachick/posts_table.gif[/img] And this is my PHP code for new_thread.php... (just FYI, lifeonmars is the admin username I'm using for testing the site. When it goes live i'll make a session for depicting the rank of the member.) [code] <?php // Copyright "the Wizarding World" 2006-2007 // Date: July 14th, 2006 // Description: Create a new thread session_start(); $user = $_SESSION['user']; $page_title = 'Create a new thread'; // Includes header + database variables + Stuff require_once('config.inc.php'); require_once('connect.php'); include('functions.php'); include('header.php'); if (isset($_GET['forum_id'])) { if (is_numeric($_GET['forum_id'])) { $forum = $_GET['forum_id']; } else { echo 'Your forum ID is invalid.'; include("footer.php"); die(); } } if (isset($_POST['submitted'])) { $errors = array(); if (empty($_POST['subject'])) { $errors[] = 'You did not choose a subject for your topic.'; } else { $subject = escape_data(htmlspecialchars($_POST['subject'])); } if (empty($_POST['body'])) { $errors[] = 'You did not enter anything in the body of your topic.'; } else { $body = escape_data(htmlspecialchars($_POST['body'])); } if (empty($_POST['forum'])) { $errors[] = 'Forum ID was incorrect.'; } else { $forum = $_POST['forum']; } if (empty($_POST['special'])) { $errors = 'You did not select the type of post to make.'; } elseif ($_POST['special'] == 1) { $special = 1; } elseif ($_POST['special'] == 2) { $special = 2; } elseif ($_POST['special'] == 3) { $special = 3; } elseif ($_POST['special'] == 4) { $special = 4; } else { $errors[] = 'You did not select a valid type.'; } if (empty($errors)) { // First, find out what the thread_id should be $query = "SELECT ABS(thread_id) FROM posts"; $result = mysql_query($query); if ($result) { $row = mysql_fetch_array($result, MYSQL_NUM); $thread_id = $row[0] + 1; $query = "INSERT INTO posts (forum_id, thread_id, subject, body, time, special) VALUES ('$forum', '$thread_id', '$subject', '$body', NOW(), '$special')"; $result = mysql_query($query); if ($query) { echo '<div align="center">Your post has been created! You are being redirected to your thread.</div>'; redirect("view_thread.php?id=$thread_id", 2); } else { echo mysql_error(); } } else { echo mysql_error(); } } else { foreach ($errors as $msg) { echo '<Li> '.$msg.'</li>'; } } } else { echo '<form action="'.$file.'" method="post"> <table border="0" class="tablestyledark" align="center" width="70%" cellpadding="7px" cellspacing="7px"> <tr><td class="tablestylelight"><b>In Forum:</b></td><td class="tablestylelight">'; if (isset($_GET['forum_id'])) { $query = "SELECT name FROM forums WHERE forum_id='$forum'"; $result = mysql_query($query); if (mysql_num_rows($result) == 1) { $row = mysql_fetch_array($result, MYSQL_NUM); echo '<i>'.$row[0].'</i>'; } else { die('Could not select forum.</td></tr></table><p><center><i>Since we could not select the form, you cannot make a post in it</center>'); } } else { die('Could not select forum.</td></tr></table><p><center><i>Since we could not select the form, you cannot make a post in it</center>'); } echo '<tr> <td class="tablestylelight"><b>Subject:</b></td><td class="tablestylelight"><input type="text" name="subject" value="'; if (isset($_POST['subject'])) { echo stripslashes($_POST['subject']); } echo '" size="51"></td></tr> </td></tr> <tr><Td colspan="2" class="tablestylelight"><b>Post Body:</b><br> <textarea name="body" rows="10" cols="63">'; if (isset($_POST['body'])) { echo stripslashes($_POST['body']); } echo '</textarea></td></tr> <tr><td class="tablestylelight" colspan="2"><input type="radio" name="special" value="1" checked> Regular Post <br>'; if ($user == 'lifeonmars') { echo '<input type="radio" name="special" value="2"> Sticky Post<br> <input type="radio" name="special" value="3"> Lock Post<br> <input type="radio" name="special" value="4"> Stickied and Locked Post<br>'; } echo '</td></tr> <tr><td colspan="2"><input type="submit" name="submit" value="Submit Post"></td></tr></table> <input type="hidden" name="forum" value="'.$forum.'"> <input type="hidden" name="submitted" value="TRUE"></form>'; } mysql_close(); include("footer.php"); ?> [/code]
×
×
  • 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.