![](https://forums.phpfreaks.com/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
wildteen88
-
Posts
10,480 -
Joined
-
Last visited
Never
Posts posted by wildteen88
-
-
For some reason strange reason this allways redirects me to the login form called main_login.php
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
-
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)
-
-
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; }
-
But if i need to change a value thats been already added. i mean existing value. what should i do ?
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);
-
Thank you very much but coders usually have a reason for asking something
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.
I need to know the last rows id that is in a tableTo 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
and then put that last rows id into the second field of mt_rand.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);
-
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.
-
So that if i just change those codes and the form code should remain same ?
Yes replace your php code with the php code I posted. You do not need to change your form.
and another question is if already my $a=1; value given can it edit that ?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';
-
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>';
-
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.
-
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.
-
Its just calling the query function within the database object ($this->db).
I think this is known as object chaining.
-
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.
-
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
-
This topic has been moved to Miscellaneous.
-
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.
-
and is '||' essentially saying 'and' if this 'and' if this
No || means OR
&& means AND
-
How do I code:
if "SESS_MEMBER_ID" and "SESS_STATUS - set to 'coach'" are both not set - access denied
or
if "SESS_MEMBER_ID" and "SESS_STATUS - set to 'player'" are both not set - access denied
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(); }
-
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.
-
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
A MultiViews search is enabled by the MultiViews Options. If the server receives a request for /some/dir/foo and /some/dir/foo does not exist' date=' then the server reads the directory looking for all files named foo.*, and effectively fakes up a type map which names all those files, assigning them the same media types and content-encodings it would have if the client had asked for one of them by name. It then chooses the best match to the client's requirements, and returns that document.[/quote'] -
Try disabling multiviews
Options -Indexes -Multiviews
-
The technique for creating pages from your query results is called pagination. Have a read through this tutorial.
-
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 />'; }
-
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; }
Php login form fault
in PHP Coding Help
Posted
what is in index.php? maybe there is something within index.php that is causing the redirect to main_login.php