wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
[SOLVED] endless loop? empty variables? what IS going on?
wildteen88 replied to dsaba's topic in PHP Coding Help
Could you post some demo data stored in es-translations.txt Also this line is weird: $english = str_replace("", "_", trim($full_line[0])); Your are replacing nothing with an underscore - You might want to place the first two parameters for the str_replace function the other way around. That way you replace underscores with nothing. You cant replace nothing with something. -
Try $_POST['websites'] instead. Your code is using old coding syles. it require register_globals - which is now depreciated and is being phased out. You should update your coding style to use superglobals to get data from GET, POST, COOKIE, SESSION, SERVER etc.
-
Whats it supposed to do. Are you getting errors? Have coded the output for returned result set yet?
-
If you dont want people to view the directory indexing Create an .htaccess file in the photos directory with this: Options -Indexes That should display a 403 forbidden error. However if you go to site.com/photos/user_123/imagename.gif the image will be shown. All what the code in the htaccess file does is prevent users from seeing a directory index. directory index lists all files/folders in a directory if there is no index file found.
-
You are echo'ing HTML/text before you use the header function. You should call the header function before you send any output to the browser. What I'd do is this: <?php $html = <<<htmlmsg <center><FORM action="" method=GET><FIELDSET> <LEGEND>User Login</LEGEND><P> Email: <INPUT type=text NAME="email"> Username: <INPUT type=text NAME="username"> <INPUT TYPE=submit NAME=submit VALUE=submit> <input type=reset name=reset value=reset> </FIELDSET><P> </FORM> htmlmsg; $dbConnect = mysql_pconnect("localhost", "root") or die("Cannot connect database"); mysql_select_db("test") or die("Cannot select database"); $user = $_GET['username']; $mail = $_GET['email']; if (isset($_GET['submit'])) { $query = "select `usrName`, `email` FROM enduser WHERE `usrName`='$user' AND `email`='$mail'"; $result=mysql_query($query) if(mysql_num_rows($result) == 1); { header( 'Location: C:\wamp\www' ) ; } else { echo 'No match found !<hr />'; } } echo $html; ?>
-
newbie problem - returning array value from function....help?
wildteen88 replied to phertzog's topic in PHP Coding Help
Your function returns a value so what you want to do is this when you call your function $my_array = get_territory_names(); $my_array will be passed the value of $territory created in the function. -
Your error is coming from this part of your SQL Query (mid way through): inquiringOn) MonthlyPlan VALUES( Notice the closing brace after the inquiringOn field but you have the MonthlyPlan field outside of the list of fields. This is what's causing this error. it should be like this: inquiringOn, MonthlyPlan) VALUES( ANd the last part of the query should be like this: '$inquiring', '$MonthlyPlan')" and not like this: '$MonthlyPlan', '$inquiring')" Your fields values where in the wrong order. You must place your fields values in the correct order you list the fields in. Otherwise the data will be added to the wrong field in your database which can cause other SQL errors/problems. Also looking at your code. This following code is redundant if($firstName){//----> CHECK input } else{ $error.="Please, go back and fill out your first name\n";//----> ERROR if no input } You have an empty if statement. It is redundant code if your leave something blank/don't use it. If thats the case don't have it in there. Just do your if statement like this instead: if(!$firstName){//----> CHECK input $error.="Please, go back and fill out your first name\n";//----> ERROR if no input } The exclamation mark (!) means NOT
-
addslashes adds slashes in front of quotes it doesn't remove quotes. strip slashes reverses what addslashes does and that remove the slashes added to the quotes. What you will want to do is use str_replace instead. To remove the quotes. $str = '"2 4 .98 .09"'; $str = str_replace('"', '', $str); echo $str;
-
Do not post duplicate help threads in different forums. Only post one instance of a help thread. The PHP Help is more relevant IMO. If your PHP script is causing the server to "overload" then that suggests to me something in your PHP script is causing it.
-
unset deletes the variable itself. That why in my code snippet I checked that $arr existed (after running unset). isset checks for variable existance not the variables value, and thus when you run the code you see the output of $arr but then you get a message saying $arr does not exist. If only want to empty a variables value just set it again with an empty value, example $arr = array(values here); // remove $arr's value $arr = null; That will now clear $arr's value and not delete the variable.
-
I'd would handle all error aspects which the file you are writing to having write permission, file not found etc in side the function itself.
-
I'd use a for loop instead to create the month pull down menu. Much better way of doing it: <select name="month"> <?php // do a loop here to create the month pull down menu // this loop runs 12 times // It will automatically output the html for us // and select the current month in list! for($i = 0; $i <= 12; $i++) { // set format of the number displayed for the month // this checks to see if $i is less than 10 // if its it'll set $m to 0x (x being a number between 1 and 9) $m = ($i < 10) ? '0' . $i : $i; // start the html for the option tag $opt = '<option value="' . $m . '" '; // this bit checks to see if the month returned from the date() is equal to $m // if its equal then we extend the value of $opt to include the // select attribute and close the opening option tag // else it will just close the option tag $opt .= (date('m') == $m) ? 'selected="selected">' : '>'; // here we extend $opt further to show the month // and close the option tag. $opt .= $m . "</option>\n"; echo $opt; } ?> </select> example HTML output: <option value="01">01</option> <option value="02" selected="selected">02</option> ... <option value="12">12</option>
-
unset deletes the variable. So if you have a variable which is amultidimensional array. It will clear its contents and delete the variable. example: // a 2D arrary $arr = array( 'level1' => array( 'item1' => 'somevalue', 'item2' => 'somet8hing else', 'level2' => array( 'anotheritem' => 'foobar', 'somethingelse' => 'bar time' ) ) ); echo '<pre>' . print_r($arr, true) . '</pre>'; // unset $arr unset($arr); // test to see if $arr exists any more. if(!isset($arr)) { echo 'variable $arr does not exist'; } else { echo 'variavle $arr exists!'; }
-
[SOLVED] Using Session Control in PHP part2
wildteen88 replied to Trium918's topic in PHP Coding Help
The latter code is correct: if (isset($_SESSION['valid_user'])) // instead of if (session_is_registered("valid_user")) { echo "You are logged in as: ".$_SESSION['valid_user']."<br>"; echo "<a href=\"logout.php\">Log out</a><br>"; } -
If you want to use a a custom font on your web page then look in to WEFT. WEFT allows you to embed non-standard fonts in your web page if the end user doesn't have your font installed on their computer. Ideally you should not use non-standard fonts on webpages. You should use standard fonts that most of your end users will have on their PCs. If you are using your font for small little things like Headings then I'd would suggest you images instead for that.
-
[SOLVED] Using Session Control in PHP part2
wildteen88 replied to Trium918's topic in PHP Coding Help
We are not here to code/recode stuff for you. But here is some tips: If you see anything like this: $valid_user = $username; session_register("valid_user"); Then change it to: $_SESSION['valid_user'] = $username; if you see session_unregister("valid_user"); use unset($_SESSION['valid_user']); If you see $valid_user change it to $_SESSION['valid_user'] -
Have a read of this basic tutorial on mod_rewrite. If I give you the mod_rewrite rules you need you're not going to learn. When doing mod_rewrite it helps if you have an understanding of basic regular expressions in order to create your your rewrite rules. mod_rewrite has nothing to do with PHP. You keep the code of your script the same. No changes should[/b] have to be made to your PHP code. The only changes that may need to be made is the format of your url's for your links.
-
I get that a lot on a few communities I go to.
-
You can change the way how die works if you wish. However you will need to know C (or what ever programming language PHP is programmed in). However what I'd do is create a function that will log the error passed to it example die(log_error('error message here', $errorLog);
-
Umm, I'm a her now lol! It doesn't matter what version you learn as... there is no difference between the two languages. Except PHP5 has better OOP functionality. If you have learnt PHP5 then you don't need to learn PHP4.
-
Because you have defined the variable $valid and thus your if statement is always going to return true.
-
You using old coding techniques In order for your code to work you will need to turn register_globals on. Turning this setting on is not recommended though as there is a reason why it is off by default. In stead what you should do is this: page1.php <?php session_start(); /* old and depreciated session_register("sess_var"); $sess_var = "Hello world!"; */ // New way $_SESSION['sess_var'] = 'Hello World'; echo "The content of \$_SESSION['sess_var'] is $_SESSION['sess_var']<br>"; echo "<a href=\"page2.php\">Next page</a>"; ?> page2.php <?php session_start(); $sess_var = $_SESSION['sess_var']; echo "The content of \$sess_var is $sess_var<br>"; /* old and depreciated session_unregister("sess_var"); */ unset($_SESSION['sess_var']); echo "<a href=\"page3.php\">Next page</a>"; ?> page3.php <?php session_start(); $sess_var = $_SESSION['sess_var']; echo "The content of \$sess_var is $sess_var<br>"; session_destroy(); ?>
-
Use this as the pattern: /[^a-z0-9\-\s]/i