Jump to content

Nhoj

Members
  • Posts

    223
  • Joined

  • Last visited

    Never

Everything posted by Nhoj

  1. I figured it out; for thos that might be curious it worked as follows: SET @rn :=0; SELECT @rn := @rn +1 AS `tempID`, `categoryID`, `categoryParent`, `categoryType`, `categoryName` FROM `categories` WHERE `categoryParent` = 0 ORDER BY `categoryName` DESC
  2. Not sure if its possible, but I have a table of categories with an autoincrement field, looks like this: categoryID categoryParent categoryType categoryName 1 0 1 Computers & Networking 2 0 1 Arts & Crafts 3 0 1 Music 4 0 1 Motor Vehicles 5 0 1 Books 6 0 1 Sporting Goods 7 2 1 Direct From Artist 8 2 1 Wholesale Lots 9 5 1 Fiction 10 5 1 Non-Fiction The categoryID is the primary key set to auto_increment on insert, nothing special. What i'd like to be able to do, if possible, is when i select only a few, using a query like 'SELECT * FROM `categories` WHERE `categoryParent` = 0', have it pull the results with its unique ID and also have a temporary column with the result number it is. So that previous query should pull something like the following: temporary categoryID categoryParent categoryType categoryName 1 7 2 1 Direct From Artist 2 8 2 1 Wholesale Lots 3 9 5 1 Fiction 4 10 5 1 Non-Fiction If anyone can enlighten, thanks! Edit: The main idea behind it is to be able to sort the results ascending, descending, or even filter them via the category type and have that tempory column always increment by 1 starting from 1 and counting through the total, regardless of how it's filtered or sorted.
  3. You could also just do it all in one query with mysql_result like so: <? $count = mysql_result(mysql_query("SELECT COUNT(*) FROM hometeam_stats WHERE gamertag_id='{$standings['gamertag_id']}' AND season='$currentseason' AND win_loss=1"), 0); echo $count; ?>
  4. As darkwater said, you will need to use cURL. http://us.php.net/manual/en/ref.curl.php
  5. You could look into phpMailer, it's a library of sorts that allows you to use send mail using SMTP. http://phpmailer.codeworxtech.com/
  6. The best way to secure a cron job would be to put it outside an accessable directory. For example, if your web documents are served from /home/user/public_html, put your crons in /home/user/crons, that way no one can access them except the server itself or people with FTP access.
  7. IE6 has some funkie session handling. Honestly, if you can figure it out that would be great. I've spent probably 10 - 12 hours on the same issue in the past and gave up. It's a very common issue: http://www.google.com/search?hl=en&q=IE6+and+php+sessions. Also there are a few suggestions for headers you can set that can be found on php.net.
  8. ?> <html> <body> <?php That part would be your problem more than likely. You cannot output ANYTHING to the browser if you are going to use any of the header() function commands after it. Try the following: <?php error_reporting(E_ALL); session_start( ); // if username and password are set and not empty then proceed with the rest of the process if( isset( $_POST[ 'username' ] ) && isset( $_POST[ 'password' ] ) && $_POST[ 'username' ] != '' && $_POST[ 'password' ] != '' ) { $link = mysql_connect( 'host', 'username', 'password' ); $db_selected = mysql_select_db('uname', $link); $username = mysql_real_escape_string($_POST['username'], $link); $password = mysql_real_escape_string($_POST['password'], $link); if (!$db_selected) { echo"Connection to the database failed. Please try again later." ; exit; } //checks for username and password in db table. $results = mysql_query("select * from users where username='" . $username . "' and password = '" . $password . "'" ,$link ) or die(mysql_error()); $num_rows = mysql_num_rows($results); //greater than zero if( $num_rows > 0 ) { $_SESSION['username'] = $username; //redirect header('Location:orion.php'); } else { echo 'You must be registered before you may log in.'; } } include( 'sessions.php' ); show_statement( ); if (isset($_SESSION['username'])) { echo '<br />'; echo 'Logged in as '.$_SESSION['username'].''; echo '<br /><a href="logout.php">Log out</a><br />'; } else { echo 'Please login to view your company files.<br />'; } ?> </body> </html> Also, what is in sessions.php? If you echo ANYTHING and then try to use header() it will give an error.
  9. got any code we can take a look at? Maybe some code that is used to display the date.
  10. echo "<form method=\"get\" action=\"battlesystem.php\">\n"; echo "<input type=\"submit\" value=\"Battle\">\n"; echo "</form>\n";
  11. As darkwater said, it looks like that number is simply the amount of time it too to create the page. Not for the page to be sent to the user.
  12. What exactly are you trying to acomplish by doing !> or !<? If you are trying to accomplish not greater than or not less than you could just flip the sign and remove the !. For example not greater than (!>) would obviously be anything less than, so <= would suffice. Anything less than or equal to is technically not greater than The same goes for the opposite.
  13. <?php $time = time(); $hms = date('H:i:s', $time); echo $hms; ?> http://us3.php.net/manual/en/function.date.php
  14. I think what he means is that: $product_id = $_GET['product_id']; doesn't appear to be sanatized. http://www.askbee.net/articles/php/SQL_Injection/sql_injection.html Might help, as if you use the $product_id to do a lookup or any interaction with MySQL you're wide open to SQL-injection attacks without sanitizing the input.
  15. You might want to look into the group by function, I think it is what you're looking for: http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html
  16. Unfortunately anything you pass into a function stay's in the function unless you return it at the end.
  17. Any variables changed or declared inside a function stay inside the function. If you want to save the changes to $allVariales you would need to add: return $allVariables; at the end of the function before the last closing brace
  18. Neither of the two include commands you listed include a file in the ../forum folder. What are the contents of the forum folder, where is it located and the file that includes forum/extern.php is it the same /root/one/two/extern.php file?
  19. Heh, try it with your telephone, for example if you have a verizon phone with SMS, send an e-mail to yournumber@vtext.com Might want to look into the php mail() function.
  20. You might want to try a simply e-mail type application that sends an e-mail to the mobile number. This might help a little http://www.tech-recipes.com/rx/939/sms_email_cingular_nextel_sprint_tmobile_verizon_virgin
  21. Try the following: <?php error_reporting(E_ALL); require_once "require/db.php"; mysql_connect("$db_host", "$db_user", "$db_pass")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $usrname = $_POST['usrname']; $pass = $_POST['pass']; if($usrname && $pass !== ""){ $usrname = stripslashes($usrname); $pass = stripslashes($pass); $usrname = mysql_real_escape_string($usrname); $pass = mysql_real_escape_string($pass); $pass = md5($pass); $sql="SELECT * FROM $db_name WHERE username='$usrname' and password='$pass'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count==1){ header("location:index2.php"); } else { header("location: index.php?msg=Incorrect Username or Password. Please try again."); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Admin</title> <link rel="stylesheet" href="style/css.css" /> </head> <body> <? if(isset($_GET['msg'])){ echo htmlentities($_GET['msg']); echo "<br />"; } ?> <form action="index.php" enctype="multipart/form-data" method="post"> <b>Username</b><br /> <input type="text" name="usrname" /><br /> <b>Password</b><br /> <input type="password" name="pass" /><br /> <input type="submit" value="Login" /> </form> </body> </html>
  22. You cannot use anything that modifies any headers after you have ANY output. For example: if($count==1){ header("location:index2.php"); } else { header("location: index.php?msg=Incorrect Username or Password. Please try again."); } cannot be used after ANYTHING has been outputted to the browser, INCLUDING <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Admin</title> <link rel="stylesheet" href="style/css.css" /> </head> <body>
  23. You probably wont need to use escapeshellcmd() unless you are using your inputs to execute a command with the system, exec, etc functions (http://us.php.net/manual/en/book.exec.php). http://us.php.net/manual/en/function.mysql-real-escape-string.php - Would probably be the best place to start.
  24. Be careful with preg_match or preg_replace... You may also want to look into mysql_real_escape_string()
×
×
  • 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.