PHP - Xampp - "notice: Undefined Variable"
Hi. I installed xampp to practice php scripting. Until today, it has worked fine, but now it says:
Notice: Undefined variable: text in E:\xampp\htdocs\Experiments\Tutorial\HelloWorld.php on line 6 What can I do to fix this? I'm told that variable don't need to be defined before being initialized, but that doesn't really mean much to me! Please help Similar Tutorialsthe array is getting the values as he should get and from there i send them to $temp (string),but when i'm trying to print them i can't. the array and the string at the end of code saved the values that the code gave them,but i can print the values one by one, but i need the values in string and the array at the end and print $temp(string) in a row without white space. print_r is working but she's not build to this job can someone look at the code and the result of the code and tell me what seem to be the problem and how to fix that? the problem start with $txt when the array is getting the values. the output of this code:http://pastebin.com/0QkzjviW the code page is attach to this message as php file. Ok soon i can't take this any more, there IS nothing wrong with this code! I've checked it, i have double checked it, tripple checked and then checked it again bit for bit and I can't find anything that suggest i should get these messages: Notice: Undefined index: birth_month in [php file location] on line 30 Notice: Undefined index: birth_day in [php file location] on line 31 Notice: Undefined index: birth_year in [php file location] on line 32 Notice: Undefined index: iagree in [php file location] on line 33 I have one file with the HTML form named "register.php" and another file with the PHP code to process the form named "class.register.php". I don't know if it matters but i have to solve this to be able to move on with my website so i'll try to bring you all the facts and info i have.. Here is the HTML file/code (register.php): Code: [Select] <?php session_start(); if(isset($_POST['register'])) { include_once('classes/class.register.php'); $register = new Register(); if($register->process()) echo "Successfully Signed Up!"; else $register->show_errors(); } $token = $_SESSION['token'] = md5(uniqid(mt_rand(),true)); ?> <!doctype html> <html> <head> <link rel="stylesheet" type="text/css" href="css/main.css"> <link rel="stylesheet" type="text/css" href="css/register.css"> <script type="text/javascript" src="js/passwordmeter.js"></script> </head> <body> <div class="center"> <!-- PHP --> <?php require("html/menu.inc"); ?> <?php require("html/layout.inc"); ?> <?php require("html/login.inc"); ?> <!-- PHP --> <div class="register"> <header>Sign Up Now!</header> <form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>"> <ul> <li> <label for="username">* Username: </label><br /> <input name="username" autofocus="on" class="rusernamefield" type="text" required="required"></input> </li> <li> <label for="first_name">* First Name: </label><br /> <input name="first_name" class="rfirstnamefield" type="text" required="required"></input> </li> <li> <label for="last_name">Last Name: </label><br /> <input name="last_name" class="rlastnamefield" type="text"></input> </li> <li> <label for="password">* Password: </label><br /> <input name="password" class="rpasswordfield" onkeyup='password_strength(this.value)' minlength="6" maxlength="30" type="password" required="required"></input> </li> <div id="password_strength_border"> <div id="password_strength" class="strength0"></div> </div> <li> <label for="email">* Email Address: </label><br /> <input name="email" class="remail" type="email" required="required" placeholder="email@address.com"></input> </li> <li> <label for="confemail">* Confirm Email Address: </label><br /> <input name="confemail" class="rconfirmemail" type="email" required="required" placeholder="email@address.com"></input> </li> <li> <label for="gender">* Gender: </label><br /> <select name="gender" required="required"> <option value="Man" selected="selected">Man</option> <option value="Woman">Woman</option> </select> </li> <li> <label for="birth_month">* Birth Day: </label><br /> <select name="birth_month" required="required"> <option disabled="disabled" selected="selected">Month</option> <option value="01">January</option> <option value="02">February</option> <option value="03">March</option> <option value="04">April</option> <option value="05">May</option> <option value="06">June</option> <option value="07">July</option> <option value="08">August</option> <option value="09">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12">December</option> </select> <select name="birth_day" required="required"> <option disabled="disabled" selected="selected">Day</option> <option value="01">1</option> <option value="02">2</option> <option value="03">3</option> <option value="04">4</option> <option value="05">5</option> <option value="06">6</option> <option value="07">7</option> <option value="08">8</option> <option value="09">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <select name="birth_year" required="required"> <option disabled="disabled" selected="selected">Year</option> <option value="2011">2011</option> <option value="2010">2010</option> <option value="2009">2009</option> <option value="2008">2008</option> <option value="2007">2007</option> <option value="2006">2006</option> <option value="2005">2005</option> <option value="2004">2004</option> <option value="2003">2003</option> <option value="2002">2002</option> <option value="2001">2001</option> <option value="2000">2000</option> <option value="1999">1999</option> <option value="1998">1998</option> <option value="1997">1997</option> <option value="1996">1996</option> <option value="1995">1995</option> <option value="1994">1994</option> <option value="1993">1993</option> <option value="1992">1992</option> <option value="1991">1991</option> <option value="1990">1990</option> <option value="1989">1989</option> <option value="1988">1988</option> <option value="1987">1987</option> <option value="1986">1986</option> <option value="1985">1985</option> <option value="1984">1984</option> <option value="1983">1983</option> <option value="1982">1982</option> <option value="1981">1981</option> <option value="1980">1980</option> <option value="1979">1979</option> <option value="1978">1978</option> <option value="1977">1977</option> <option value="1976">1976</option> <option value="1975">1975</option> <option value="1974">1974</option> <option value="1973">1973</option> <option value="1972">1972</option> <option value="1971">1971</option> <option value="1970">1970</option> <option value="1969">1969</option> <option value="1968">1968</option> <option value="1967">1967</option> <option value="1966">1966</option> <option value="1965">1965</option> <option value="1964">1964</option> <option value="1963">1963</option> <option value="1962">1962</option> <option value="1961">1961</option> <option value="1960">1960</option> <option value="1959">1959</option> <option value="1958">1958</option> <option value="1957">1957</option> <option value="1956">1956</option> <option value="1955">1955</option> <option value="1954">1954</option> <option value="1953">1953</option> <option value="1952">1952</option> <option value="1951">1951</option> <option value="1950">1950</option> <option value="1949">1949</option> <option value="1948">1948</option> <option value="1947">1947</option> <option value="1946">1946</option> <option value="1945">1945</option> <option value="1944">1944</option> <option value="1943">1943</option> <option value="1942">1942</option> <option value="1941">1941</option> <option value="1940">1940</option> <option value="1939">1939</option> <option value="1938">1938</option> <option value="1937">1937</option> <option value="1936">1936</option> <option value="1935">1935</option> <option value="1934">1934</option> <option value="1933">1933</option> <option value="1932">1932</option> <option value="1931">1931</option> <option value="1930">1930</option> <option value="1929">1929</option> <option value="1928">1928</option> <option value="1927">1927</option> <option value="1926">1926</option> <option value="1925">1925</option> <option value="1924">1924</option> <option value="1923">1923</option> <option value="1922">1922</option> <option value="1921">1921</option> <option value="1920">1920</option> <option value="1919">1919</option> <option value="1918">1918</option> <option value="1917">1917</option> <option value="1916">1916</option> <option value="1915">1915</option> <option value="1914">1914</option> <option value="1913">1913</option> <option value="1912">1912</option> <option value="1911">1911</option> <option value="1910">1910</option> <option value="1909">1909</option> <option value="1908">1908</option> <option value="1907">1907</option> <option value="1906">1906</option> <option value="1905">1905</option> <option value="1904">1904</option> <option value="1903">1903</option> <option value="1902">1902</option> <option value="1901">1901</option> <option value="1900">1900</option> </select> </li> <li> <label for="iagree" class="iagreetext">* I Agree to the <a href="#">Privacy Policy</a> and <a href="#">Terms of Use</a></label> <input name="iagree" type="checkbox" required="required" class="iagreebox"></input> </li> <input name="register" class="registerbutton" type="submit" value="Sign Up"></input> <p class="fieldsmarked">Fields marked with an (*) is required</p> <input type="hidden" name="token" value="<?php echo $token;?>"/> </ul> </form> </div> </div> </body> </html> And here is the PHP file/code (class.register.php): <?php class Register { private $username; private $first_name; private $last_name; private $password; private $passmd5; private $email; private $gender; private $birth_month; private $birth_day; private $birth_year; private $iagree; private $errors; private $token; public function __construct() { $this->errors = array(); $this->username = $this->filter($_POST['username']); $this->first_name = $this->filter($_POST['first_name']); $this->last_name = $this->filter($_POST['last_name']); $this->password = $this->filter($_POST['password']); $this->email = $this->filter($_POST['email']); $this->gender = $this->filter($_POST['gender']); $this->birth_month = $this->filter($_POST['birth_month']); $this->birth_day = $this->filter($_POST['birth_day']); $this->birth_year = $this->filter($_POST['birth_year']); $this->iagree = $this->filter($_POST['iagree']); $this->token = $_POST['token']; $this->passmd5 = md5($this->password); } public function process() { if($this->valid_token() && $this->valid_data()) $this->register(); return count($this->errors)? 0 : 1; } public function filter($var) { return preg_replace('/[^a-zA-Z0-9@.]/','',$var); } public function register() { mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db("membership") or die (mysql_error()); $sql = "INSERT INTO users(username,password,first_name,last_name,email,gender,birth_month,birth_day,birth_year) VALUES ('{$this->username}','{$this->passmd5}','{$this->first_name}','{$this->last_name}','{$this->email}','{$this->gender}','{$this->birth_month}','{$this->birth_day}','{$this->birth_year}')"; mysql_query($sql) or die(mysql_error()); if(mysql_affected_rows()< 1) $this->errors[] = "<div class=errormessages>Could Not Process Form</div>"; } public function user_exists() { mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db("membership") or die (mysql_error()); $data = mysql_query("SELECT username FROM users WHERE username = '{$this->username}'"); return mysql_num_rows($data) > 0 ? 1 : 0; } public function show_errors() { foreach($this->errors as $key=>$value) echo "<div class=errormessages> $value </div> <br />"; } public function valid_data() { if ($this->user_exists()){ $this->errors[] = 'The username is already taken, choose another one!'; } if (empty($this->username)){ $this->errors[] = 'You must enter a username!'; } if (empty($this->first_name)){ $this->errors[] = 'You must enter your first name'; } if (empty($this->password)){ $this->errors[] = 'You must enter a password!'; } elseif (strlen($this->password) < 6){ $this->errors[] = 'Your password must be longer than 6 characters!'; } if (empty($this->email)){ $this->errors[] = 'You must enter an email address!'; } elseif (!preg_match('/^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z]{2,4}$/',$this->email)){ $this->errors[] = 'Your password can only contain these characters: a-z, A-Z and 0-9!'; } if (empty($this->confemail)){ $this->errors[] = 'You need to confirm your email address!'; } elseif ($this->confemail != $this->email){ $this->errors[] = 'The email addresses you entered did not match!'; } if (empty($this->birth_month)){ $this->errors[] = 'Select which month you were born!'; } if (empty($this->birth_day)){ $this->errors[] = 'Select which day you were born!'; } if (empty($this->birth_year)){ $this->errors[] = 'Select which year you were born!'; } if (empty($this->iagree)){ $this->errors[] = 'You must agree to the <a href="#">Privacy Policy</a> and <a href="#">Terms of Use to sign up!'; } return count($this->errors)? 0 : 1; } public function valid_token() { if(!isset($_SESSION['token']) || $this->token != $_SESSION['token']) $this->errors[] = "<div class=errormessages>Invalid Submission</div"; return count($this->errors)? 0 : 1; } } ?> I really need help with this.. So if you have 10 min or so to scroll through my code and see if you can see any direct faults i would really appreciate it! Cause I can't find anything wrong with it! Note: I tried to solve it by changing the top part of the PHP code from: $this->birth_month = $this->filter($_POST['birth_month']); $this->birth_day = $this->filter($_POST['birth_day']); $this->birth_year = $this->filter($_POST['birth_year']); $this->iagree = $this->filter($_POST['iagree']); To: $this->birth_month = $this->filter($_POST['birth_month'] = ""); $this->birth_day = $this->filter($_POST['birth_day'] = ""); $this->birth_year = $this->filter($_POST['birth_year'] = ""); $this->iagree = $this->filter($_POST['iagree'] = ""); That did take away the messages but instead whenever i for example chose a date in the dropdown menu it would always return false.. I have 2 issues happening, first one I need to get resolved is, line 60 is giving me a 'Notice: Undefined variable: delete'. This codes had multi issues but was able to resolve all but this one and my table not filling in with the data from my database. If you need any other info please let me know, Again I am new at this.
<tr> <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete value="delete"></td> </tr> <?php // Check if delete button active, start this *line 60* -----> if ($delete){ for($i=0;$i<$count;$i++){ $del_id = $checkbox[$i]; $sql = "DELETE FROM $tbl_name WHERE id='$del_id'"; $result = mysqli_query($sql); } // if successful redirect to delete_multiple.php if($result){ echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\">"; } } mysqli_close($con); ?> Have got a form for the user to fill in. When they press submit the page SHOULD be sent to itself and update the database. When I load the page I keep getting undefined variable "submit" and also when i press button and bottom I get 404 message. <?php include "variables.php"; ?> <?php $date = date("M d, Y"); if ($submit) { // process form $db = mysql_connect($databaseserver, $databaseuser, $databasepass); mysql_select_db($databasename,$db); $sql = "UPDATE $playerstable SET staff = '$staff' WHERE name='$name'"; $result = mysql_query($sql); echo "Thank you! Information entered.<br><a href='$directory/Admin/index.php'>Return to admin panel</a>"; } else{ // display form ?> <form method="post" action="<?php echo $PHP_SELF?>"> <center> <table border="0" cellpadding="0" width="100%"> <tr> <td width="12%"> Name:</td> <td width="88%"><select size="1" name="name"> <?php $db = mysql_connect($databaseserver, $databaseuser, $databasepass); mysql_select_db($databasename,$db); $sortby = "name ASC"; $sql="SELECT * FROM $playerstable ORDER BY $sortby"; $result=mysql_query($sql,$db); $num = mysql_num_rows($result); $cur = 1; echo "<ol>"; while ($num >= $cur) { $row = mysql_fetch_array($result); $name = $row["name"]; ?> <option><?php echo "$name" ?></option> <?php $cur++; } echo "</ol>"; ?> </select></td> </tr> <tr> <td width="12%"> Staff:</td> <td width="88%"><select size="1" name="staff"> <option>Yes</option> <option>No</option> </select></td> </tr> </table> </center> <p> <input type="Submit" name="submit" value="Enter information"> </form> <?php } ?> hi, I need help really badly for my PHP-Postcard Script. Basically it sends the card out but the URL does not work, I get the following error message: The URL is not valid and cannot be loaded It also states that Notice: Undefined index: www.voluntary.awardspace.co.uk in /home/www/voluntary.awardspace.co.uk/Postcard.php on line 25 Notice: Undefined index: Postcard.php in /home/www/voluntary.awardspace.co.uk/Postcard.php on line 25 See Code below: <?php session_start(); //check error log ini_set('display_errors', 1); ini_set('log_errors', 1); ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); error_reporting(E_ALL); // CHANGE PARAMETERS HERE BEGIN $senderName = " Holidays From Home "; // Eg.: John's Postcards $senderEmail = "chris01@voluntary.awardspace.co.uk"; // Eg.: john@postcard.com // Change only if you have problems with urls $postcardURL = "http://".$_SERVER["www.voluntary.awardspace.co.uk"].$_SERVER["Postcard.php"]; // CHANGE PARAMETERS HERE END $result = 0; $msg = ""; $msg1 = ""; $pic = ""; function displayPhotos() { global $pic; $columns = 5; $act = 0; $act1 = 0; // Open the actual directory if($handle = opendir("thumbs")) { // Read all file from the actual directory while($file = readdir($handle)) { if(!is_dir($file)) { if(isset($pic[1])) { if($pic[1] == $act1){$sel = "checked";} else{$sel = "unchecked";} } if($act == 0){echo "<tr>";} echo "<td align='center'><img src='thumbs/$file' alt='postcard'/><br/><input type='radio' name='selimg' value='$file,$act1' $sel/></td>"; $act++; $act1++; if($act == $columns){$act = 0;echo "</tr>";} } } echo "</tr>"; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <head> <title>Micro Postcard</title> <link href= "style/style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="main"> <div class="style1" id="caption"> <div align="left" class="style1"></div> </div> <?php //makes sure form is correctly filled in if(!empty($_POST["submit"])) { if(empty($_POST["selimg"])){$msg = "Please select an image from above!";$result = 3;} else{$pic = explode(",",$_POST["selimg"]);} if(empty($_POST["email"]) && empty($result)){$msg1 = "You must enter an email address!";$result = 3;} $secCode = empty($_POST["secCode"]) ? "" : strtolower($_POST["secCode"]); if($secCode == $_SESSION["securityCode"] && $result != 3) { $filename = date("YmdGis"); $f = fopen("messages/".$filename.".txt","w+"); fwrite($f,$pic[0]."\n"); fwrite($f,$_POST['email']."\n"); fwrite($f,stripslashes($_POST["message"])."\n"); fclose($f); // Compose the mail $from = "From: $senderName <$senderEmail>\r\n"; $replay = "Reply-To: $senderEmail\r\n"; $params = "MIME-Version: 1.0\r\n"; $params .= "Content-type: text/plain; charset=iso-8859-1\r\n"; $mailtext = "You have just received a Virtual Postcard!\r\n\r\n You can pick up your postcard at the following web address:\r\n $postcardURL?show=$filename\r\n\r\n We hope you enjoy your postcard, and if you do, please take a moment to send a few yourself!\r\n\r\n Regards,\r\n Holidays From Home\r\n $postcardURL"; // Send email @mail($_POST["email"],"You've received a postcard",$mailtext,$from.$replay.$params); echo "<center> Your postcard was sent successfully!<br /><br /> <img src='images/$pic[0]' alt='postcard' /><br /><br /><br />".stripslashes($_POST["message"]). "</center>"; $result = 1; } else{if($result != 3){$result = 2;}} } if(!empty($_GET["show"])) { $file = $_GET["show"]; $content = file("messages/$file.txt"); $pic = $content[0]; unset($content[0]); unset($content[1]); foreach($content as $value){$main .= $value;} echo "<center> Your postcard!<br /><br /> <img src='images/$pic' alt='postcard' /><br /><br /><br />$main </center>"; } if((empty($result) || $result == 2 || $result == 3) && empty($_GET["show"])) { echo "<form action='#' method='post'> <table align='center'>"; displayPhotos(); echo "</table> <div style='color:#f00;font-size:16px;'>$msg</div> <h2>Fill in the Form and then click on Send Card!!</h2> <table width='100%'> <tr><td>Send to (email address):</td><td><div style='color:#f00;font-size:16px;'>$msg1</div><input type='text' name='email' size='30' value='".$_POST["email"]."' /></td></tr> <tr><td>Message:</td><td><textarea name='message' rows='10' cols='40'>".stripslashes($_POST["message"])."</textarea></td></tr> <tr><td colspan='2'>".($result == 2 ? "<p style='color:#f00;font-size:16px;'>Sorry the security code is invalid! Please try it again!</span></p>" : " ")."</tr> <tr> <td>Security code: <input class='text' name='secCode' type='text' size='10' /> </td><td><img src='securityCode.php' alt='security code' border='1' /></td> </tr> <tr><td colspan='2'> </tr> <tr><td colspan='2' align='left'><input type='submit' value='Send card!' name='submit'/></td></tr> </table> </form>"; } ?> Absolutely any help would be much appreciated. I want ot know is there a way round this problem? Here is the http://voluntary.awardspace.co.uk/Postcard.php I am absolutely desperate to solve this burning issue Can someone please help me with an array problem i can not figure out. I need the array to be numbered from 1 to how ever many fields that are needed in the form and have a mysql field name and the title of the field also in the array. 1, "mysql_field_name", "Title of form field" 2, "", "" and so on then the form will be shown based on the array. I have the following draft code which I am working with. any suggestions on how i may do this array ? Code: [Select] <?php $options = array( '1'=> array('fieldtext'=>'option1', 'mysqlfield'=>'option1'), '2'=> array('fieldtext'=>'option2', 'mysqlfield'=>'option2'), '3'=> array('fieldtext'=>'option3', 'mysqlfield'=>'option3'), '4'=> array('fieldtext'=>'option4', 'mysqlfield'=>'option4'), ); // $options = array(1 => "option1", "option2", "option3", "option4"); // the line above works but i want to include the name of the mysql field as well. $userid = 1; ?> <div style="align: center; margin: 12px; font-family:Tahoma;"> <br><br><?php if ($_POST['Update'] != "Update") { // check if form submitted yet, if not get data from mysql. $res = db_query("SELECT * FROM `users` WHERE `userid` = '" . $userid . "'"); foreach($options as $key => $value) { $_POST[$key] = mysql_result($res, 0, $value); } $ok_to_update = "no"; } elseif ($_POST['Update'] == "Update") { // check if form submitted yet, if so get POST data. // error checking // foreach($options as $key => $value) { // $_POST[$i] = ""; // } $ok_to_update = "yes"; } if ($_POST['Update'] == "Update" && $ok_to_update == "yes") { // $res = db_query("INSERT INTO `users` () VALUES ()"); // add user details to database. ?><p><br><br><br>Thank you for updating</p><?php } else { ?><form name="form1" method="post" action=""> <?php foreach($options as $key => $value) { ?><p><?php echo($value); ?>: <input type="text" name="<?php echo($key); ?>" value="<?php echo($_POST[$key]);?>"></p> <?php } ?> <input name="Update" type="submit" value="Update"> </form> <?php } ?> </div> Hi, bit stuck on how to find and replace "<" and ">" with "<" and ">". I basically have a database record that outputs to screen and I need the code in the <code> tags to be rendered to the screen. I therefore need it to go through the whole array variable from the db and change the symbols just inside the code tags. Please be aware that the code tags might happen more than once here's an example below Code: [Select] <p>blah blah blah</p> <p>blah blah blah</p> <p>blah blah blah</p> <code> <h1>hello</h1> </code> <p>blah blah blah</p> <p>blah blah blah</p> <p>blah blah blah</p> <code> <h1>hello</h1> </code> the desired output would be: <p>blah blah blah</p> <p>blah blah blah</p> <p>blah blah blah</p> <code> <h1>hello</h1 </code> <p>blah blah blah</p> <p>blah blah blah</p> <p>blah blah blah</p> <code> <h1>hello</h1 </code> help on this would be great Cheers Rob Hi guys I am a newbie with PHP and I have been trying to solve this problem for 3 days.. Ive set up a booking form on my website to be sent directly to my email once the client clicked on the send button.. The problem I am having while checking these pages on wamp is that the booking form is ok but when I click on the send button the following message error appears "Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\fluffy_paws\booking_form2.php on line 27" When I check online I have this message "500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed." Are my codes wrong??? My webhosting is Blacknight.com , Im on Windows Vista, my internet is a dongle with O2 ireland Thanks for your help! $query = "SELECT * FROM School_Registrations WHERE School_Name= '$_POST[SchoolName]' "; $result2 = mysql_query($query); if (mysql_numrows($result2) > 0) { while($row = mysql_fetch_array($result2)) { echo" <h2>ERROR</h2> ...rest of the error code... ";} } else { mysql_query("INSERT INTO ``.`` (...all the variables...);") or die(mysql_error( 'Location: http://www...php' )); echo " ...success code... $url = 'http://www.mypage.com/page.php?'; $url .= 'email='.urlencode($_POST['email']); $result = getPage('', $url, '', 15); function getPage($proxy, $url, $header, $timeout) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, $header); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_PROXY, $proxy); curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_REFERER, 'http://mypage.org'); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8'); $result['EXE'] = curl_exec($ch); $result['INF'] = curl_getinfo($ch); $result['ERR'] = curl_error($ch); curl_close($ch); return $result; } } ?> Ok, so this code verifies what the name entered in the forms is not already in database. If it is it gives you the ...error code... and nothing else. If it does not it gives you ...success code... and it creates new table record, and it sends out email address entered to designated page. Bu I keep getting: Fatal error: Call to undefined function getPage() It still fully works, but no email goes out as defined. I am stuck. Help? Hi guys I'm struggling a bit, I need to replace a word that occurs multiple times in text with an array("up","down","forward","backwards") of words. $find = "left"; $replace = array("up","down","forward","backwards"); $text = "left left left left"; echo str_replace($find,$replace,$text); The Output is: array array array array Did try this with a foreach statement as well, but no luck. Is there a better way of doing this? Thanks cant work out this mysql syntax error "operation":"medupdate","medid":"","name":"ibo","medyear":"5","medmonth":"21","medday":"1","recuser":1,"SuccFail":"fail","SuccFailMessage":"error occured You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '''WHERE med_id=' at line 2","ResultData":""} Code: [Select] $sql="update metodology set med_description='".$req['name']."', med_year='".$req['medyear']."', med_month='".$req['medmonth']."', med_day='".$req['medday']."', med_recorddate= now(), med_recorduserid= 1'"; $sql.= " WHERE med_id=".$req['medid']; I have just re-installed Xampp and suddenly my sites are now displaying lots of: Notice: Use of undefined constant name - assumed 'name' in ... Notice: Use of undefined constant price - assumed 'price' in ... this is an example of the line its refering too: $defineProducts[1001] = array(name=>'This is a product', price=>123); I'm trying to sort out a piece of code, my development web server is set to show all errors. I'm currently getting 50+ 'Undefined Index' errors upon initial load (they all disappear after form submission since all variables are in use). Should I be worried, and add a if(isset(.....)){...} wrapper or do most people just leave it be? I'm getting the following notice: Notice: Undefined variable: TotaalBerichten in C:\Users\Sander\Documents\**********************\index.php on line 60 Is it because it is in the IF? The code: //Aantal berichten totaal if (!$ResultTotaalBerichten = @mysql_query("SELECT COUNT(1) FROM " . $db_prefix . "berichten")) {$foutmelding .= $Taal['errorConfiguratieFromDB'];} else {$TotaalBerichten = mysql_result($ResultTotaalBerichten, 0); $TotaalPaginas = ceil($TotaalBerichten / $aantalBerichtenPerPagina);} @mysql_free_result($ResultTotaalBerichten); //Var eersteBericht is het eerste bericht if (isset($_GET['eersteBericht'])) {if (!is_numeric($_GET['eersteBericht'])) {$eersteBericht = '0';} else{$eersteBericht = $_GET['eersteBericht'];}} else{$eersteBericht = '0';} // Als er iets mis is met var eersteBericht, dan hem op 0 zetten if (($eersteBericht >= $TotaalBerichten) || ($eersteBericht < 0)) ///////////DIT IS LIJN 60 {$eersteBericht = 0;} EDIT: translated to english If i modify it to: $TotaalBerichten=0; /////////////ADDED //Aantal berichten totaal if (!$ResultTotaalBerichten = @mysql_query("SELECT COUNT(1) FROM " . $db_prefix . "berichten")) {$foutmelding .= $Taal['errorConfiguratieFromDB'];} else {$TotaalBerichten = mysql_result($ResultTotaalBerichten, 0); $TotaalPaginas = ceil($TotaalBerichten / $aantalBerichtenPerPagina);} @mysql_free_result($ResultTotaalBerichten); echo $TotaalBerichten; //////////////////////////////////////////////////////////////////////////ADDED //Var eersteBericht is het eerste bericht if (isset($_GET['eersteBericht'])) {if (!is_numeric($_GET['eersteBericht'])) {$eersteBericht = '0';} else{$eersteBericht = $_GET['eersteBericht'];}} else{$eersteBericht = '0';} // Als er iets mis is met var eersteBericht, dan hem op 0 zetten if (($eersteBericht >= $TotaalBerichten) || ($eersteBericht < 0)) ///////////DIT IS LIJN 60 {$eersteBericht = 0;} The $TotaalBerichten is '0' while there IS a message in the database??? Hello! Help me please!
My site nice work on php version 5.2.12, but now php version is changed to 5.2.17 and some code is not working.
It showing error:
"Notice: Undefined variable: newCode in ....../humancheck.php on line 29"
In file humancheck.php on line 29:
for($i=0; $i<$config_max_digits;$i++) $newCode = $newCode.rand(0,9);This variable, it seems, taken from another file - humancheck_showcode.php: session_start(); $newCode = $HTTP_SESSION_VARS["newCode"];And, in index.php file at the beginning of the file written: require ('human_check/humancheck.php');And, in index.php file below is written: <IMG src="humancheck_showcode.php">When I call the index.php file it shows error. So, I think, that variable "newCode" should be taken from file humancheck_showcode.php, but it don't do that. Hello all - am looking for help with dynamic links in PHP not returning data and coughing out "Notice: Undefined variable: row in /home/jj3wg2td/public_html/Uni More Info.php on line 200" The initial search is being fed from a mysql into table of results in another page ('ViewMore' being a column in my database and 'UniversityCourses' being the trigger to search that column): echo "<td class='result'><a href='Uni More Info.php?ID={$row['UniversityCourses']}'>{$row['ViewMore']}</a></td>"; This is working fine as I can see the various links changing when you hover over them in the table. clicking the links goes to "Uni More Info.php" where my PHP code is: <?php session_start(); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); //Connect to the database $mysqli = new mysqli("localhost", "jj3wg2td_wix", "MYPASSWORD", "MYDATABASE"); if(isset($_GET['post'])){ $ID=mysqli_real_escape_string($mysqli, $_GET['ID']); $sql="SELECT * FROM uni2020 WHERE UniversityCourses='$ID'"; $result=mysqli_query($mysqli,$sql) or die ("Bad Query: $sql"); $row=mysqli_fetch_array($result); if(isset($_GET['post'])){ $Website=mysqli_real_escape_string($mysqli,$_GET['Website']); $UcasPointsRequired=mysqli_real_escape_string($mysqli,$_GET['UcasPointsRequired']); $OverallScore=mysqli_real_escape_string($mysqli,$_GET['OverallScore']); $sql= "INSERT INTO UniversityCourses (Website, UcasPointsRequired) VALUES ('$Website', $UcasPointsRequired');"; $result=mysqli_query($mysqli,$sql) or die ("Bad Query: $sql"); } } ?> <content> <?php echo $row['Website']?> <?php echo $row['UcasPointsRequired']?> <?php echo $row['OverallScore']?> </content> The error codes are showing:
Notice: Undefined variable: row in /home/jj3wg2td/public_html/Uni More Info.php on line 200 Which is the section in-between the <content></content> tags. Reading up into "Undefined Variable", it suggest that I havent "Declared the variables", but isn't that this section?: if(isset($_GET['post'])){ $Website=mysqli_real_escape_string($mysqli,$_GET['Website']); $UcasPointsRequired=mysqli_real_escape_string($mysqli,$_GET['UcasPointsRequired']); $OverallScore=mysqli_real_escape_string($mysqli,$_GET['OverallScore']); I am new to PHP and am learning as I go along....but yet again...I'm stumped! Any help is very much appreciated (again)!!!!
Steven I don't know why I am getting an undefined variable when the url is define. look at the deleteid=6 it means it is defined and in the code it is written as below URL Quote http://www.ppp.com/storeprueba/storeadmin/inventory_list.php?deleteid=6 Code: [Select] <?php if(isset($_GET['deleteid'])){ //which is clearly active in the url then get it, /* line 27 ===> */ echo'Do you really want to delete pdoruct with ID of '. $GET ['deleteid'] . '? <a href="inventory_list.php?yesdelete=' . $GET ['deleteid'] . '">Yes</a> |<a href="inventory_list.php"> No</a>'; exit(); } if (isset($_GET['yesdelete'])) { // remove item from system and delete its picture // delete from database $id_to_delete = $_GET['yesdelete']; $sql = mysql_query("DELETE FROM products WHERE id='$id_to_delete' LIMIT 1") or die (mysql_error()); // unlink the image from server // Remove The Pic ------------------------------------------- $pictodelete = ("../inventory_images/$id_to_delete.jpg"); if (file_exists($pictodelete)) { unlink($pictodelete); } header("location:inventory_list.php"); exit(); } ?> the echo Code: [Select] <?php echo 'Do you really want to delete pdoruct with ID of '. $GET ['deleteid'] . '? <a href="inventory_list.php?yesdelete=' . $GET ['deleteid'] . '">Yes</a> |<a href="inventory_list.php"> No</a>'; ?> won't display the . $GET ['deleteid'] . after "Do you really want to delete product with ID of which is 6 but it won't display the number six with the actual configuration, instead it display it like Quote Notice: Undefined variable: GET in /home3/nyhungry/public_html/storeprueba/storeadmin/inventory_list.php on line 27 Notice: Undefined variable: GET in /home3/nyhungry/public_html/storeprueba/storeadmin/inventory_list.php on line 27 Do you really want to delete pdoruct with ID of ? Yes | No Notice not number in between 'ID of' and '?' Code: [Select] <form method="post" action=""> <input type="input" name="user_name" /> <input type="submit" name="user_name_submit" /> </form> <?php if(!empty($_POST['user_name'])) $user_name = $_POST['user_name']; if(isset($_POST['user_name_submit'])) { $user_name_submit = $_POST['user_name_submit']; } $user_name_preg_match = preg_match('/[a-zA-Z0-9]/', $user_name); if($user_name_preg_match) { echo 'true'; } else { echo 'false'; } ?> In this script I am getting the notice: Code: [Select] Notice: Undefined variable: user_name Any suggestions how to avoid the notice in this case? Hello i am new to this forum and coding. I am trying to fix a auto torrent downloading script which is php and curl. I have been stucked with Undefined offset error. Your help will be very appretiated, thanks. Starting download: Mp3-data1 Notice: Undefined variable: temp in /var/www/html/torrents/bgrahul2.php on line 338 Array ( => HTTP/1.1 200 OK Server: Transmission Content-Type: application/json; charset=UTF-8 Date: Wed, 21 Sep 2011 19:58:44 GMT Content-Length: 49 {"arguments":{"torrents":[]},"result":"success"} [1] => ) Marked those lines to bold Quote $result = callTransmission(array("filename" => "/var/www/html/donofwarez/xxx/torrents/$torrentfile", "download-dir" => "/home/Downloads/$title/"), "torrent-add", $arr[1]); callTransmission(array("seedRatioLimit" => 50, "seedRatioMode" => 1), "torrent-set", $arr[1]); /* echo "<pre>"; print_r($result); echo "</pre>"; */ if (preg_match('/"percentDone":[0-9.]+/i', $result[0], $matches)) $temp = str_replace('"id":', "", $matches[0]); // $temp="hlDr1wqu2ONtM3McVGHoVzfrkp2UgUcGwDt66IuxAe0LBkru"; $id[0] = $temp; //***OMG! We need the ids as integers! *** foreach ($id as $key => $value) { $id[$key] = (int) $value; } Ik ben bezig met een gastenboek en snap de volgende foutmelding niet: Notice: Undefined variable: iCountFiles *************** regel 261 //Smilies toegestaan? if ($GetConfiguratie['smiley'] == 1) {$AfbeeldingenPerRegel = 12 ; if (!$rHandle = opendir('./images/smilies')) {$sP_Smilies = 'Geef de map "smilies" leesrechten!';} else {$sP_Smilies = ''; while (false !== ($sFile = readdir($rHandle))) {if (preg_match("/^([sa-zA-Z0-9]+){3}(:?\.gif|\.jpg)$/", $sFile)) { $sFileShort = preg_replace("/^([sa-zA-Z0-9]+)(:?\.gif|\.jpg)$/", "(\\1)",$sFile); $iCountFiles++ ; /////////////////////////////////////////////////////////////REGEL261 if ($iCountFiles % $AfbeeldingenPerRegel == 0) {$sP_Smilies .= '<img onClick="insertSmilie(\''.$sFileShort.'\')" src="images/smilies/'.$sFile.'" alt="code: '.$sFileShort.'" /><br />';} else {$sP_Smilies .= '<img onClick="insertSmilie(\''.$sFileShort.'\')" src="images/smilies/'.$sFile.'" alt="code: '.$sFileShort.'" /> ';} } } closedir($rHandle); } } hoe los ik dit het best op? |