Jump to content

ucffool

Members
  • Posts

    100
  • Joined

  • Last visited

Contact Methods

  • Website URL
    http://www.phpreferencebook.com

Profile Information

  • Gender
    Male
  • Location
    Denver, CO

ucffool's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. If you just want the query string to be PASSED ON (they go to /home?something=else and it redirects to home.html?something=else), just add the following flag at the end of the rule: [QSA] For instance: RewriteRule ^/product/([0-9]*)/? /product.php?product_id=$1 [QSA] Maybe I'm just not understanding your question.
  2. It's the little things (also, use <?php in your code so it is color coded): Original: <?php include("dbase.incl.php"); $Title=$_POST['Title']; $Author=$_POST['Author']; $EMail=$_POST['EMail']; $Type_id=$_POST['Type']; $Func_id=$_POST['Func']; $Cost_id=$_POST['Cost']; $Rating_id=$_POST['Rate']; $Description=$_POST['Description']; mysql_connect($hostname,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query1 = "SELECT author.Author, author.Author_id FROM author WHERE Author='$Author'"; $result1=mysql_query($query1); $num=mysql_num_rows($result1); if ($num =(0)) { $query2 = "INSERT INTO author.Author, author.EMail VALUES ('$Author', '$EMail')"; mysql_query($query2); $query3 = "SELECT author.Author_id FROM author WHERE Author = '$Author'"; $result2=mysql_query($query3); $Author_id=mysql_result($result2,1,'Author_id'); } else { $Author_id=mysql_result($result1,1,'Author_id'); // ** This was where it was ** } $query4 = "INSERT INTO items VALUES ('','$Title','$Cost_id','$Type_id','$Func_id','$Rating_id','$Author_id','$Description')"; mysql_query($query4); mysql_close(); ?> Fixed: <?php include("dbase.incl.php"); $Title=$_POST['Title']; $Author=$_POST['Author']; $EMail=$_POST['EMail']; $Type_id=$_POST['Type']; $Func_id=$_POST['Func']; $Cost_id=$_POST['Cost']; $Rating_id=$_POST['Rate']; $Description=$_POST['Description']; mysql_connect($hostname,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query1 = "SELECT author.Author, author.Author_id FROM author WHERE Author='$Author'"; $result1=mysql_query($query1); $num=mysql_num_rows($result1); if ($num == 0) { // <--- fixed $query2 = "INSERT INTO author.Author, author.EMail VALUES ('$Author', '$EMail')"; mysql_query($query2); $query3 = "SELECT author.Author_id FROM author WHERE Author = '$Author'"; $result2=mysql_query($query3); $Author_id=mysql_result($result2,1,'Author_id'); } else { $Author_id=mysql_result($result1,1,'Author_id'); // ** This was where it was ** } $query4 = "INSERT INTO items VALUES ('','$Title','$Cost_id','$Type_id','$Func_id','$Rating_id','$Author_id','$Description')"; mysql_query($query4); mysql_close(); ?> Also, remember that mysql_result(resource,row,column), where column can be the column heading or a number. Example from my book: <?php //nametable: |pkey| name | // |----|------| // Row 0: | 3 | Mark | // Row 1: | 2 | John | $result = mysql_query("SELECT * FROM nametable"); var_dump( mysql_result($result, 0) ); var_dump( mysql_result($result, 1) );?> string(1) "3" string(1) "2" <?php var_dump( mysql_result($result, 0, 1) ); var_dump( mysql_result($result, 1, 'name') ); string(4) "Mark" string(4) "John" ?>[/code]
  3. You are doing: $content = addslashes($content); Yet not doing stripslashes() before outputting it. Not sure if that's your only issue, but it's a start.
  4. Maybe you should check out: http://www.phpfreaks.com/forums/index.php/board,8.0.html
  5. <?php $sql = "SELECT col1,col2,col3,t2agent,COUNT(t2agent) as total FROM data WHERE MONTH(`tdate`) = '$month' GROUP BY t2agent ORDER BY total DESC"; ?>
  6. I think this is your issue: if ( $num != 0 & password == $md5pass) { Should be: if ( $num != 0 && password == $md5pass) {
  7. You can setup another divider besides a forward slash (fake folders). You could have the url be something like: variablename~value/events.html The key is something unique. How you build your URL is your choice, just need to make the mod_rewrite understand it.
  8. For a fun idea, why don't you build a script to capture the user agent, parse it for the operating system, and check it against your database. In one table you have the user agent and its 'general' category (windows2000 for instance). In another table, you have a list of every user agent operating system parse. If it is found in the second table, check the first and save the info. If it is NOT in the second table, save it in the second table with a flag column set to 1. Then, once a week, process the flagged agents and categorize them manually. You'll be collecting them and generating the list as you go. Kinda sounds like fun (but I'm twisted).
  9. I would also add a query string variable on the 'read more' link like ?disp=all Then on the same page you can alter the code from Jabop: <?php $string='asdfasdfasdfasdfadfasdfasdfadfadfadfasdfadfadfasdfadfadfsdfsdfsdfafasdsdfsdfsdfsdfdf'; $disp = $_GET['disp']; if (strlen($string)>130 && !$disp=='full') { echo substr($string, 0, 130) . ' read more omg click here'; } else { echo $string; } ?>
  10. Wait wait wait! No moving on just yet Have you got an index on the username column on your users table? You shouldn't need to break the table up like that to get adequate performance. You may also need indexes on other values if you do frequent lookups by those values. Just to clarify, he is referring to mysql indexing. Here is an indepth article on it: http://www.informit.com/articles/article.aspx?p=377652
  11. If you also have a low number of visitors, that causes issues as well (besides the extra overhead). See if your webhost (I use dreamhost, they can do this) supports cronjobs. These are scheduled actions, such as running a php file. You could have that run daily or hourly, and make a specific file that will run the checks and email processing. I use it to do maintenance on a cache, uploads, and old items on one of my sites. There are more complex methods, but this is the simplest approach.
  12. You can use a form to get the file upload, then save the file contents temporarily, read the file (file_get_contents) into a variable which you can dump into the mysql database. Finally, delete the temporary file. Here is some info on file uploads in php: http://www.w3schools.com/PHP/php_file_upload.asp
  13. Try displaying all errors on the page and see if you get anything new: error_reporting(E_ALL); ini_set('display_errors', '1');
  14. As Ken said, you can go in and out of html and php and not lose out on anything. So if you have: <?php $world = 'World!'; ?> <html> <p>Hello World!</p> <p>Hello <?php echo $world; ?></p> It will work perfectly fine.
  15. Use output buffering. ob_start(); // generate the data $output = ob_get_contents(); ob_end_flush(); // Send the output to the page // later in the page, just echo $output.
×
×
  • 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.