Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Everything posted by wildteen88

  1. what is in index.php? maybe there is something within index.php that is causing the redirect to main_login.php
  2. I cant see how as the code you posted does not contain anything that will cause this. The only redirect checklogin.php has is to login_success.php
  3. Can you post a better explanation to your problem. Your posts are not making much sense to me. Could you also post your code too (wrap it within or tags)
  4. This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=337128.0
  5. You don't position the text using PHP. You use html/css for this. Example HTML/CSS code for floats <div class="float-container"> <div class="left">text on the left side</div> <div class="right">text on right side</div> </div> And the CSS .float-container { width: 100%; overflow: auto; } .left { float: left; } .right { float: right; }
  6. Rather than use a simple string replacement $contents = str_replace($oldline, $newline, $contents); You can do a more complex string replacement using regular expressions. This line should make changes to existing values $contents = preg_replace('~\$'.$letter.' =.+?;~s', $newline, $contents);
  7. I was just assuming you was going to be using mt_rand to select a random row from your table latter on in your script. That why I mentioned you can select random rows from within your query it self. To get the last row you use a query like this SELECT id FROM `business` ORDER BY id DESC LIMIT 1 that query will get the last row from the business table Something like this should work $result = mysql_query("SELECT id FROM `business` ORDER BY id DESC LIMIT 1"); list($last_row_id) = mysql_fetch_row($result); $rand = mt_rand(0, $last_row_id);
  8. Are you trying to select a random row from your database. You can do this within your query SELECT * FROM table ORDER BY rand() LIMIT 1 The above query will select one random row from the table. Change Limit 1 to the number of random rows you want the query to return.
  9. Yes replace your php code with the php code I posted. You do not need to change your form. No, it will not replace the variables that already have a value. It will only change lines like $a = ; to $a = 'value from form field a';
  10. To add $data array to the $alldata array, you'd use this within your while loop $alldata[] = $data; After your loop you can see the data stored within the $alldata array using print_r echo '<pre>' . print_r($alldata, true) . '</pre>';
  11. That is called type hinting. Which mean it is enforcing that the $db argument must be an instance of the MySQL object when the parent class is initiated.
  12. Because your code is overwriting your files contents with $string = '<?php $a = "'. $_POST["a"]. '" . "\n"; $b = "'. $_POST["b"]. '" . "\n"; $c = "'. $_POST["c"]. '" . "\n"; $d = "'. $_POST["d"]. '" . "\n"; $e = "'. $_POST["e"]. '" . "\n"; $f = "'. $_POST["f"]. '". "\n"; $g = "'. $_POST["g"]. '". "\n"; ?>'; It will not just change these lines of code $a = ; $b = ; $c = ; $d = ; $e = ; $f = ; $g = ; You first need to get the contents of config.php $contents = file_get_contents('config.php'); Then replace the variable in config.php using $var_letters = range('a', 'g'); foreach($var_letters as $letter) { $oldline = '$' . $letter . ' = ;'; $newline = '$' . $letter . ' = \'' . $_POST[ $letter ] . '\';'; echo "Replacing <tt>$oldline</tt> with <tt>$newline</tt><br />"; $contents = str_replace($oldline, $newline, $contents); } Now save the new contents to config.php file_put_contents('config.php', $contents); Your variables $a to $g should now be set in config.php with the values you typed within your form.
  13. Its just calling the query function within the database object ($this->db). I think this is known as object chaining.
  14. You can use functions such as var_dump which will print information about a variables data type and its value. You can also get a backtrace using debug_print_backtrace The most important tool when developing code is setting error_reporting to E_ALL and setting display_errors to on within your php.ini. That way any errors occur they will displayed during runtime.
  15. Functions have their own variable scope. Meaning any variables that are defined outside of them are not available within them. The same applies with variable you define within the function are available outside of them. To get around this you need to pass the $database variable to your GetAlerts() function. Manual page on Variable Scope and Functions
  16. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=337087.0
  17. Breakpoints have nothing to do with PHP. They are handled by your code editor, specifically IDE's. There are many IDEs available for PHP. A few of them are listed in this thread. If you're using Firefox you can install firebug and firephp. You can then use firephp to debug your code form your browser.
  18. Like so // define the people to allow access $people_to_allow = array('coach','player'); if ( !(isset($_SESSION['SESS_MEMBER_ID']) && is_numeric($_SESSION['SESS_MEMBER_ID'])) || // check that SESS_MEMBER_ID is set and contains a number !(isset($_SESSION['SESS_STATUS']) && in_array($_SESSION['SESS_STATUS'], $people_to_allow)) // check that SESS_STATUS is set and that is in the $people_to_allow array ) { header("location: access-denied.php"); exit(); }
  19. What do you links look like? Also in order for this rule to work RewriteRule ^/([A-Za-z0-9]+)$ $1.php You need to remove the forward slash.
  20. multiviews allows you to call for files without stating their extension. When it is enabled you can call site.com/about.php using site.com/about Explanation from the manual
  21. Try disabling multiviews Options -Indexes -Multiviews
  22. The technique for creating pages from your query results is called pagination. Have a read through this tutorial.
  23. Use an if statement to see if there is a value for sex and age // sample data to work with $data['name'] = 'Joe'; $data['sex'] = ''; $data['age'] = ''; echo 'Name: ' . $data['name'] . '<br />'; // Display the sex if its not empty if(!empty($data['name'])) { echo 'Sex: '. $data['sex'] . '<br />'; } // Display the age if its not empty if(!empty($data['age'])) { echo 'Age: '. $data['age'] . '<br />'; }
  24. You cannot use trim that way. You have to compare the return value of trim() to an empty string to check whether $_POST['answer1'] is emtpy. if(trim($_POST['answer1']) == '') { $errors = true; }
×
×
  • 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.