PHP - Get_include_contents() Is Undefined?
Well, I was searching for a way to save the output of and included file to a string and I find out that I can use get_include_contents(), as it says in the end of the include manual (http://php.net/manual/en/function.include.php). But when I use it PHP says that it's undefined
I'm using XAMPP portable, could be that? :S Does this function work on your version of PHP? Sorry fot my english Similar TutorialsHello, I have just upgraded my wampserver and with it MySQL, PHP and PhpMyAdmin versions. And my scripts, which ran normally before, not burst hundreds of undefined variable and undefined index notices. I realize it's "notices", not "errors" but this is quite irritating. I believe it might be due to some upgrade in PHP scripting rules or something but I don't know what. I hope you can help me. The first type of notice is "undefined variable". This function will return the notice if I remove the bold red line, where I define the variable as empty before I use it in the loop. I didn't need to do this before. function statistics($array) { [color=red][b]$list = '';[/b][/color] if(is_array($array)) { foreach($array as $name => $value) { // Rip out the name of the client. $list .= "<li>".$name." - "; // set an integer so we know how many tier2 values we have read. $x = 0; foreach($value as $difference => $sum_total) { // if this is the more than the first tier2 values, use a '+' between the units. $list .= (++$x > 1) ? " + ".$sum_total." ".$difference : $sum_total." ".$difference; } // close the line out. $list .= "</li>"; } } return $list; } To avoid the 10+ like notices on the page I declare them empty before the variable's first occurrence. But this sounds stupid to me. Wasn't this one of PHP's benefits, not to have to declare the variable before using it? I also get about 30+ undefined index notices, e.g. Quote Notice: Undefined index: COMPANY XXX in F:\wamp\www\Project Management\main.php on line 37 Notice: Undefined index: USD in F:\wamp\www\Project Management\main.php on line 37 Notice: Undefined index: USD in F:\wamp\www\Project Management\main.php on line 41 Here are those lines: $income_total = calculate("income"); foreach($income_total as $row) { $clientID = $row['clientID']; $clientname = $row['clientname']; //$client = "<a href=\"index.php?page=Client&do=view&clientID=$clientID\">".$clientname."</a>"; $client = "<a href=\"index.php?page=Project&do=view&sortby=$clientID\">".$clientname."</a>"; $currency = $row['currency']; $client_sum = $row['client_sum']; $year_sum = ''; $year_sum += $client_sum; $income = ''; $income[$client][$currency] += $client_sum; $income_list = statistics($income); $income_all = ''; $income_all[$currency] += $client_sum; } Line 37 is: Quote $income[$client][$currency] = It's the values assigned to $client and to $currency that seem to cause the notice. How do I deal with this? I don't just want to turn error/notice display off, I want to resolve this issue. I am pretty sure I defined these, by making it something like $blah="blah" and `blah` = ' {$blah}' So why am I getting these errors = Notice: Use of undefined constant petid - assumed 'petid' in /home/vhosts/foggyjungle.6te.net/viewpet_forum.php on line 38 Notice: Use of undefined constant adopter - assumed 'adopter' in /home/vhosts/foggyjungle.6te.net/viewpet_forum.php on line 41 Notice: Undefined variable: fulldate in /home/vhosts/foggyjungle.6te.net/viewpet_forum.php on line 44 Fatal error: Call to undefined function showpet_forum() in /home/vhosts/foggyjungle.6te.net/viewpet_forum.php on line 45 $time = mysql_query("SELECT * FROM `pets_adopted`"); $date = mysql_fetch_array($time); $fulldate = "$date[fulldate]"; $halfdate = "$date[halfdate]"; function check(){ $pid = mysql_real_escape_string($_GET['id']); $result = mysql_query("SELECT * FROM `pets_adopted` WHERE `id` = '{$pid}'"); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $results = mysql_query("SELECT * FROM `pets_list` WHERE `id` = '{$row[petid]}'"); $pet = mysql_fetch_array($results); $results2 = mysql_query("SELECT * FROM `users` WHERE `id` = '{$row[adopter]}'"); $usercc = mysql_fetch_array($results2); There's the snippet. Thank you for any help. I am just really lost. please help! I am getting undefined index and offset when I duplicated my SEARCH page for when logged in here is my code Code: [Select] <?php include_once("config.php"); include_once("functions.php"); // Check user logged in already: checkLoggedIn("yes"); ?> <!doctype html> <html> <head> <title>Retro and Vintage</title> <meta name="description" content="xxx" /> <meta name="keywords" content="xxx" /> <meta name="Content-Language" content="en-gb" /> <meta name="robots" content="FOLLOW,INDEX" /> <meta name="revisit-after" content="2 days" /> <meta name="copyright" content="jbiddulph.com" /> <meta name="author" content="John Biddulph - Professional web site design and development in the south of england mainly worthing and brighton" /> <meta name="distribution" content="Global" /> <meta name="resource-type" content="document" /> <link rel="stylesheet" type="text/css" href="css/reset.css" /> <link rel="stylesheet" type="text/css" href="css/style.css" title="default" /> <link rel="alternate stylesheet" type="text/css" href="css/style1.css" title="1" /> <link rel="alternate stylesheet" type="text/css" href="css/style2.css" title="2" /> <script type="text/javascript" src="js/stylechanger.js"></script> <script type="text/javascript" src="js/jquery-1.2.1.pack.js"></script> <script type="text/javascript"> function lookup(inputString) { if(inputString.length == 0) { // Hide the suggestion box. $('#suggestions').hide(); } else { $.post("rpc.php", {queryString: ""+inputString+""}, function(data){ if(data.length >0) { $('#suggestions').show(); $('#autoSuggestionsList').html(data); } }); } } // lookup function fill(thisValue) { $('#inputString').val(thisValue); setTimeout("$('#suggestions').hide();", 200); } </script> </head> <body> <?php if($messages) { displayErrors($messages); }?> <header> <div id="title"> <h1>My Pub Space <a href="#" onClick="setActiveStyleSheet('default'); return false;"><img src="images/0.gif" width="15" height="15" border="0" alt="css style" /></a> <a href="#" onClick="setActiveStyleSheet('1'); return false;"><img src="images/1.gif" width="15" height="15" border="0" alt="css style" /></a> <a href="#" onClick="setActiveStyleSheet('2'); return false;"><img src="images/2.gif" width="15" height="15" border="0" alt="css style" /></a> <span> <form method="post" class="textbox" action="search1.php"> City/Town: <input type="text" size="26" class="searchbox" value="" id="inputString" onKeyUp="lookup(this.value);" onBlur="fill();" /> <div class="suggestionsBox" id="suggestions" style="display: none;"> <img src="images/upArrow.png" style="position: relative; top: -36px; left: 105px; z-index:1;" alt="upArrow" /> <div class="suggestionList" id="autoSuggestionsList"> </div> </div> <input type="image" src="images/go.png" height="30" with="30" value="GO" /> </form> </span> </h1> </div> </header> <nav> <ul> <li class="selected"><a href="#">Home</a></li> <li><a href="#">Pubs</a></li> <li><a href="#">Members</a></li> <li><a href="#">Events</a></li> <li><a href="#">Register</a></li> </ul> </nav> <section id="intro"> <header> <h2>Your social guide to going down the pub, online!</h2> </header> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut.</p> <img src="images/pub.jpg" alt="pub" /> </section> <div id="content"> <div id="mainContent"> <section> <article class="blogPost"> <header> <h2>This is the title of a blog post</h2> <p>Posted on <time datetime="2009-06-29T23:31+01:00">June 29th 2009</time> by <a href="#">Mads Kjaer</a> - <a href="#comments">3 comments</a></p> </header> <?php // drop out of PHP mode to display the plain HTML: $Townsearch = $_GET['rsTown']; echo $Townsearch; // Delimiters may be slash, dot, or hyphen list($Town, $County) = split('[,]', $Townsearch); $tableName="pubs"; $targetpage = "search1.php"; $limit = 20; $query = "SELECT COUNT(*) as num FROM $tableName WHERE rsTown LIKE '$Town%'"; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages['num']; $stages = 3; $page = mysql_escape_string($_REQUEST['page']); if( isset($_REQUEST['page']) && ctype_digit($_REQUEST['page']) ) { $page = (int) $_GET['page']; $start = ($page - 1) * $limit; }else{ $start = 0; } // Get page data $query1 = "SELECT * FROM $tableName WHERE rsTown LIKE '$Town%' LIMIT $start, $limit"; $result = mysql_query($query1); // Initial page num setup if ($page == 0){$page = 1;} $prev = $page - 1; $next = $page + 1; $lastpage = ceil($total_pages/$limit); $LastPagem1 = $lastpage - 1; $paginate = ''; if($lastpage > 1) { $paginate .= "<div class='paginate'>"; // Previous if ($page > 1){ $paginate.= "<a href='$targetpage?page=$prev'>previous</a>"; }else{ $paginate.= "<span class='disabled'>previous</span>"; } // Pages if ($lastpage < 7 + ($stages * 2)) // Not enough pages to breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } } elseif($lastpage > 5 + ($stages * 2)) // Enough pages to hide a few? { // Beginning only hide later pages if($page < 1 + ($stages * 2)) { for ($counter = 1; $counter < 4 + ($stages * 2); $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } $paginate.= "..."; $paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>"; $paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>"; } // Middle hide some front and some back elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2)) { $paginate.= "<a href='$targetpage?page=1'>1</a>"; $paginate.= "<a href='$targetpage?page=2'>2</a>"; $paginate.= "..."; for ($counter = $page - $stages; $counter <= $page + $stages; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } $paginate.= "..."; $paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>"; $paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>"; } // End only hide early pages else { $paginate.= "<a href='$targetpage?page=1'>1</a>"; $paginate.= "<a href='$targetpage?page=2'>2</a>"; $paginate.= "..."; for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } } } // Next if ($page < $counter - 1){ $paginate.= "<a href='$targetpage?page=$next'>next</a>"; }else{ $paginate.= "<span class='disabled'>next</span>"; } $paginate.= "</div>"; } echo $total_pages.' Results'; // pagination echo $paginate; ?> <ul> <?php while($row = mysql_fetch_array($result)) { echo '<li>'.$row['rsPubName'].', '.$row['rsTown'].', '.$row['rsCounty'].'</li>'; if ($_SESSION["rsUser"] == "admin") { echo "<a href=\"edit.php?PUBID=".$row['PubID']."\" class=\"small\">edit this pub</a>"; } } ?> </ul> </article> </section> <section id="comments"> <h3>Comments</h3> <article> <header> <a href="#">George Washington</a> on <time datetime="2009-06-29T23:35:20+01:00">June 29th 2009 at 23:35</time> </header> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut.</p> </article> <article> <header> <a href="#">Benjamin Franklin</a> on <time datetime="2009-06-29T23:40:09+01:00">June 29th 2009 at 23:40</time> </header> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut.</p> </article> <article> <header> <a href="#">Barack Obama</a> on <time datetime="2009-06-29T23:59:00+01:00">June 29th 2009 at 23:59</time> </header> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut.</p> </article> </section> <form action="#" method="POST" method="post"> <h3>Post a comment</h3> <p> <label for="name">Name</label> <input name="name" id="name" type="text" required /> </p> <p> <label for="email">E-mail</label> <input name="email" id="email" type="email" required /> </p> <p> <label for="website">Website</label> <input name="website" id="website" type="url" /> </p> <p> <label for="comment">Comment</label> <textarea name="comment" id="comment" required></textarea> </p> <p> <input type="submit" value="Post comment" /> </p> </form> </div> <aside> <section> <header> <h3>Members Login Area</h3> </header> <h4>Welcome <? print($_SESSION["rsUser"]); ?></h4> <a href="logout.php">Logout</a> </section> <section> <header> <h3>Archives</h3> </header> <ul> <li><a href="#">December 2008</a></li> <li><a href="#">January 2009</a></li> <li><a href="#">February 2009</a></li> <li><a href="#">March 2009</a></li> <li><a href="#">April 2009</a></li> <li><a href="#">May 2009</a></li> <li><a href="#">June 2009</a></li> </ul> </section> </aside> </div> <footer> <div> <section id="about"> <header> <h3>About</h3> </header> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco <a href="#">laboris nisi ut aliquip</a> ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> </section> <section id="blogroll"> <header> <h3>Blogroll</h3> </header> <ul> <li><a href="#">NETTUTS+</a></li> <li><a href="#">FreelanceSwitch</a></li> <li><a href="#">In The Woods</a></li> <li><a href="#">Netsetter</a></li> <li><a href="#">PSDTUTS+</a></li> </ul> </section> <section id="popular"> <header> <h3>Popular</h3> </header> <ul> <li><a href="#">This is the title of a blog post</a></li> <li><a href="#">Lorem ipsum dolor sit amet</a></li> <li><a href="#">Consectetur adipisicing elit, sed do eiusmod</a></li> <li><a href="#">Duis aute irure dolor</a></li> <li><a href="#">Excepteur sint occaecat cupidatat</a></li> <li><a href="#">Reprehenderit in voluptate velit</a></li> <li><a href="#">Officia deserunt mollit anim id est laborum</a></li> <li><a href="#">Lorem ipsum dolor sit amet</a></li> </ul> </section> </div> </footer> </body> </html> error lies on these lines Code: [Select] // drop out of PHP mode to display the plain HTML: $Townsearch = $_GET['rsTown']; echo $Townsearch; // Delimiters may be slash, dot, or hyphen list($Town, $County) = split('[,]', $Townsearch); my current code: Code: [Select] $Townsearch = $_REQUEST['rsTown']; list($Town, $County) = split('[,]', $Townsearch); ltrim($County,1); I am getting undefined index and undefined offset, so I tried this: Code: [Select] if $_REQUEST['rsTown'] == ''{ $Townsearch = ''; } else { $Townsearch = $_REQUEST['rsTown']; } but this brought back: Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in D:\retroandvintage.co.uk\wwwroot\main.php on line 6 Can someone please help? thanks 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 Hi there i keep getting an error: Notice: Undefined index: ShipYard in C:\wamp\www\SWB2\test3.php on line 160 Heres the relevant select query: Code: [Select] // COUNT SHIPYARDS $colname_shipyard = 'Empire'; mysql_select_db($database_swb, $swb); $query_shipyard = sprintf("SELECT SUM(ShipYard) FROM planet WHERE PlayerName = %s", GetSQLValueString($colname_shipyard, "text")); $shipyard = mysql_query($query_shipyard, $swb) or die(mysql_error()); $row_shipyard = mysql_fetch_assoc($shipyard); $totalRows_shipyard = mysql_num_rows($shipyard); The error is pointing to: Code: [Select] echo $row_shipyard['ShipYard'];Im a bit of a noob and have tried changing to: Code: [Select] echo $row['ShipYard']; When i do this i get a different error: Notice: Undefined variable: row in C:\wamp\www\SWB2\test3.php on line 159 The row ShipYard is in a table called planet but its not suppose to be indexed or unique. Am I missing something here?? Thanks hi... i'm getting an undefined offset for the associative arrays [28-46] in this format. $sql="INSERT INTO tableName (name1, name2, name3, name4... this goes all the way to name46) VALUES ('".$data[0]."', '".$data[1]."', '".$data[2]."', '".$data[3]."' ...this goes all the way to name46)"; $sqlData = mysql_query($sql); i have read that i can prevent the notices by doing the following, but it's not working for me: $sql="INSERT INTO tableName ( 'name1' => "isset(.$data[0].) ? $data[0] : 'default value'", 'name2' => "isset(.$data[1].) ? $data[1] : 'default value'", 'name3' => "isset(.$data[2].) ? $data[2] : 'default value'", 'name4' => "isset(.$data[3].) ? $data[3] : 'default value'", #this goes all the way to name46 )"; $sqlData = mysql_query($sql); can anyone please assist me? Hi, I have an undefined index problem and not sure how to fix it. I dont want to turn off errors - I would like to learn how to actually fix this problem. It happens in line 13 which is marked below with //line 13 comment. The exact error is: Notice: Undefined index: synonymsearch in C:\wamp\www\ezsynonym\index.php on line 13 TIA. Code: [Select] <?php //start buffering output ob_start(); include("db.php"); $mysqli = new mysqli($dbServer, $dbUser, $dbPass, $dbName); //report any errors on screen for debugging //echo "connection errors: " . mysql_error() . "<BR>"; //STORE THE USER INPUT IN VARIABLES $strErrorResults = ""; $strWordResults = ""; //line 13 - this is where the error happens. $queryWord = $_REQUEST['synonymsearch']; if ($queryWord == "" || $queryWord == "Search Synonym") { $strWordResults = "Enter a word to search for"; } else { //search for target word in wordlist $result = $mysqli->query("select * from wordlist where word='{$queryWord}'"); if ($result->num_rows > 0) { //extract the target word's primary key $word_arr = $result->fetch_array(MYSQLI_ASSOC); $word_id = $word_arr['pri']; //search for target word's primary key in the links table's wordid column $synonymQuery = "select * from links where wordid='{$word_id}'"; $synonymResult = $mysqli->query($synonymQuery); $arrKeys = array(); //create an array if ($synonymResult->num_rows > 0) { //grab the corresponding synonym ids and store into the array while ($row = $synonymResult->fetch_array(MYSQLI_ASSOC)) { $arrKeys[] = $row['synid']; } } foreach ($arrKeys as $value) { $sQuery = "select * from wordlist where pri='{$value}'"; $result = $mysqli->query($sQuery); $result_arr = $result->fetch_array(MYSQLI_ASSOC); // echo $result_arr['word']; $strWordResults .= <<<END <div id="results-left"><a href="index.php?synonymsearch={$result_arr['word']}"> {$result_arr['word']} </a></div><br/><br/> END; } // end for } // end if else { //word does not exist in the database $strErrorResults .= <<<END <p>failure... word does not exist in the system</p> END; } } print <<<END <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="style.css" type="text/css" media="screen"> <link rel="icon" href="favicon.ico" type="image/x-icon"> <title>ezSyonym</title> </head> <body> <div id="header"> <a href="index.php"><img src="images/logo-final.gif"></a> </div> <div id="content"> <div id="left-col"> <div id="searchbox"> <form id="searchform" method="post" action="index.php"> <input id="input" name="synonymsearch" type="text" value="Search Synonym" maxlength="400px" /> </form> </div> <div id="search-results"> {$strErrorResults} {$strWordResults} </div> </div> <div id="right-col"> <div id="sidebar"> </div> </div> </div> <div id="footer"></div> </body> </html> END; //send data to the browser ob_end_flush(); ?> Hi all, When i run the code below he gives the variable $naantal below he got the number i put in with ?undefined after it. Code: [Select] <?php $id = $_GET["id"]; $naantal = $_GET["aantal"]; $wijzig ="UPDATE care_medicijnen SET aantal=$naantal WHERE $id=id"; echo $wijzig; if(isset($_GET["id"])) { mysql_query($wijzig); } ?> When my input is the number 8 he gives this as output: Quote UPDATE care_medicijnen SET aantal=8?undefined WHERE 4160962=id How can i fix this that i only got the number 8 without ?undefined after it. already thanks What causes this error?? Quote Notice: Undefined index: firstname in /Users/user1/Documents/DEV/htdocs/index.php on line 2 TomTees Hi all, I'm currently adding something to my website which makes the user input some information before they enter the site, but I'm getting errors saying.. Notice: Undefined index: realname in /home/a5908246/public_html/next.php on line 24 Notice: Undefined index: gamer in /home/a5908246/public_html/next.php on line 48 But with them errors its not showing the actual form where you post the info into. <?php session_start(); include ("includes/config.php"); include ("includes/functions.php"); logincheck(); ini_set ('display_errors', 1); error_reporting (E_ALL); $username = $_SESSION['username']; $get = mysql_query ("SELECT * FROM users WHERE username='$username'") or die (mysql_error()); $got = mysql_fetch_object($get); ?> <html> <head> <title>Please Update..</title> </head> <body> <form action='' method='POST' name='everything'> <?php if ($got->realname == ''){ if ($_POST['realname']){ // Line 24 $input = $_POST['nameinput']; ?> <table width='50%' border='1' class='tableborder2' cellspacing='1' align='center'> <tr> <td class='e_header' align='center'>Error!</td> </tr> <tr> <td class='omg' align='center'>Please Enter your Real Name.</td> </tr> <tr> <td align='center'><input type='text' name='nameinput' class='textinput'></td> </tr> <tr> <td align='center'><input type='button' name='realname' class='button' Value='Update Name!'></td> </tr> </table> <br /> <?php mysql_query ("UPDATE users SET realname='$input' WHERE username='$username'") or die (mysql_error()); }} ?> <?php if ($got->gamertag == ''){ if ($_POST['gamer']){ // Line 48 $inputgamer = $_POST['gamertag']; ?> <table width='50%' border='1' class='tableborder2' cellspacing='1' align='center'> <tr> <td class='e_header' align='center'>Error!</td> </tr> <tr> <td class='omg' align='center'>Please Enter your Gamertag.</td> </tr> <tr> <td align='center'><input type='text' name='gamertag' class='textinput'></td> </tr> <tr> <td align='center'><input type='button' name='gamer' class='button' Value='Update Gamertag!'></td> </tr> </table> <?php mysql_query ("UPDATE users SET gamertag='$inputgamer' WHERE username='$username'") or die (mysql_error()); }} if ($got->realname != '' || $got->gamertag != ''){ // Display, welcome $realname, redirecting you to main site now... (2 seconds waiting) ?> <table width='50%' border='1' class='tableborder2' cellspacing='1' align='center'> <tr> <td class='header' align='center'>Welcome!</td> </tr> <tr> <td class='omg' align='center'>Welcome!</td> </tr> <tr> <td align='center'>You will be redirected to the main site in 2 seconds!<meta http-equiv="refresh" content="2;url=http://******.com/index2.php"></td> </tr> </table> </form> <?php } ?> Thanks for any help/advice given I've done this before and I've never gotten this notice, why am I getting it now? <p> <center><form method = "post" action = ""> <input type = "text" name = "name"> <input type = "password" name = "pass"> <input type = "submit" name = "submit"> </form> </center> </p> '; if($_POST['submit']){ echo"blah"; } Notice: Undefined index: submit I am having a problem with some php code that runs on a landing page that queries a database for the content needed to display on the template page from the keywords passed in the url. My issue is that when I tried to add some php code to the template page it reads it fails and returns Notice: Use of undefined constant tdbd_name - assumed 'tdbd_name' in /var/www/ppcindex.php on line 147 Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /var/www/ppcindex.php on line 150 If anyone could point me in the right direction it would be much appreciated. Here is the code from the landing page php <?php // template variables - PLEASE CHANGE error_reporting(E_ALL); ini_set('display_errors','On'); define("TEMPLATE_NAME","ppcindexcontent.php"); // your page templates define("FULL_PATH","/var/www/speedppc/"); // true path to your speedPPC install directory define("MAX_ROWS",1); // maximum display rows for CSV data - we recommend no more the 100 records if(!isset($_GET["CSVID"])){ define("CSVID", "18"); // CSVID of your csv file. leave blank if passing csvid in the url (See README.txt) } else { define("CSVID", $_GET[csvid], true); } define("REPLACECHAR", '-'); // this is the replacement character for the custom function replace() // include files include(FULL_PATH."config.php"); include(FULL_PATH."common.php"); // variables passed in URL $csvkeyword = $_GET['csvkeyword']; $seed = $_GET['seed']; $expansion = $_GET['expansion']; $final = $_GET['final']; // connect to DB $dbhandle = dbconnect($host, $user, $pass, $db); // functions function replaceTokens($passedContent) { global $csvkeyword, $seed, $expansion, $final; $tokens = array("[%csvkeyword%]", "[%seed%]", "[%expansion%]", "[%final%]", "[%Csvkeyword%]", "[%Seed%]", "[%Expansion%]", "[%Final%]"); $tokenValues = array(rs($csvkeyword), rs($seed), rs($expansion), rs($final), uc(rs($csvkeyword)), uc(rs($seed)), uc(rs($expansion)), uc(rs($final))); $replacedContent = str_replace($tokens, $tokenValues, $passedContent); return $replacedContent; } function stripUndefinedTokens($passedContent) { $patterns = '/\[%.*?(%\]|\]|%)/'; $result = preg_replace($patterns, '', $passedContent); return $result; } function changeCase($passedContent) { $patterns = '/\$.*?\]/'; $string = $passedContent; preg_match_all($patterns, $string, $matches); $uniqueMatches = array_unique($matches[0]); foreach($uniqueMatches as $key => $value) { if(substr($value, 13, 1) == strtoupper(substr($value, 13, 1))) { $string = str_replace($value, '".ucwords('.strtolower($value).')."', $string); } } return $string; } function replaceChar($passedContent) { $string = $passedContent; $patterns = '/replace\(.*?\)/'; preg_match_all($patterns, $string, $matches); $replaceChar = '-'; foreach($matches[0] as $key => $value) { $valueReplaced = str_replace(' ', REPLACECHAR, $value); $string = str_replace($value, $valueReplaced, $string); } $replace = array("replace(", ")"); //$string = str_replace($replace, '', $string); return $string; } function rs($passWord) { return str_replace('-', ' ', $passWord); } function uc($passWord) { return ucfirst($passWord); } // get CSV table Information $sql = "SELECT * FROM tabledb_details WHERE tdbd_id = '".CSVID."'"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); // replace '-' in keyword with space and also use keyword with '-' in it incase it is part of the word $keywordsArray = explode(",", $csvkeyword); $i = 0; foreach($keywordsArray as $key => $value) { $keywords[$i] = $value; $i++; $position = strpos($value, '-'); if($position !== false){ $keywords[$i] = str_replace("-", " ", $value); $i++; } } // CSV fields to search keyword occurence in $keywordFields = explode("|", $row[tdbd_search_fields]); $sqlKeyword = ' ('; foreach($keywords as $key => $value) { $sqlKeyword .= "("; foreach($keywordFields as $keyField => $valueField) { $sqlKeyword .= "`" . $valueField . "` REGEXP '( |^)".$value."( |s|[\.]|$)' OR "; } $sqlKeyword = substr($sqlKeyword, 0, -4); $sqlKeyword .= ") OR "; } $sqlKeyword = substr($sqlKeyword, 0, -4).')'; // set the default sql 'where' section if the keyword is not defined in url if($csvkeyword == '' || !isset($csvkeyword)) { $sqlKeyword = '1'; } // start template Display Output ob_start(); include(TEMPLATE_NAME); $output = ob_get_contents(); ob_end_clean(); // get the position of the loop template $loopStart = strpos($output,"[start_csv_loop]"); $loopEnd = strpos($output,"[end_csv_loop]"); // get the loop template layout $loopTemplate = substr($output, ($loopStart+16), ($loopEnd-($loopStart+16))); // get content before loop template $preContent = stripslashes(stripUndefinedTokens(addslashes(replaceTokens(substr($output, 0, $loopStart))))); // get content after loop template $postContent = stripslashes(stripUndefinedTokens(addslashes(replaceTokens(substr($output, $loopEnd+14))))); // output pre content eval("\$preContent = \"$preContent\";"); print_r( replaceChar($preContent) ); $sqlSearch = "SELECT * FROM ".$row[tdbd_name]." WHERE ".$sqlKeyword." LIMIT ".MAX_ROWS; $resultSearch = mysql_query($sqlSearch); while($displayrows = mysql_fetch_assoc($resultSearch)) { $display = replaceTokens($loopTemplate); $display = str_replace('\\', '[backslash]', $display); $display = str_replace('[%', '$displayrows[', $display); $display = addslashes(str_replace('%]', ']', $display)); $display = replaceTokens($display); $display = changeCase($display); eval("\$display = \"$display\";"); $display = stripslashes($display); $display = str_replace('[backslash]', '\\', $display); $display = replaceChar($display); print_r( $display ); } // output post content eval("\$postContent = \"$postContent\";"); print_r( replaceChar($postContent) ); ?> And here is part of the template (ppcindexcontent.php) the above code is reading. <div style=" float:right; width: 300px; height: 0px; margin-top:-20px ; margin-bottom:0px"> <p style=" font-size:16px; text-align: center; line-height:1; color:#0391D1;"> <?php error_reporting(E_ALL); ini_set('display_errors','On'); $mySQLServer = "xxxxxx"; $mySQLUser = "xxxxxxxx"; $mySQLPass = "xxxxxxxxx"; $mySQLDB = "xxxxxxxxxxx"; $SQLToday = date("m/d/y") . "<br />"; $SQLsevendays = mktime(0,0,0,date("n"),date("j")-7,date("Y")); $SQLsevenname = (date("l", $SQLsevendays)); $SQLsevennumber = (date("jS", $SQLsevendays)); $dbhandle = mssql_connect($mySQLServer, $mySQLUser, $mySQLPass) or die("Couldn't connect to SQL Server on $myServer"); $selected = mssql_select_db($mySQLDB, $dbhandle) or die("Couldn't open database $myDB"); $query = "WEB_ApproveHistory @State='CA', @Days=5, @Records=8"; $data = mssql_query($query); $result = array(); while ($row = mssql_fetch_object($data)) : $result[] = $row; $returnedresults = (97*($row->TotalApprovals)) ; endwhile; $englishreturnedresults = number_format($returnedresults); echo 'In just the last week since ' . $SQLsevenname . ' the ' . $SQLsevennumber . ' xx '; echo $englishreturnedresults; echo ' to People Just Like you In California. <br><br>Here are just a few people who' ; echo '<ul class="BulletCheck">'; mssql_next_result($data); while ($row = mssql_fetch_object($data)) : $result[] = $row; echo '<li>' . ' ' . $row->FirstName . ' From '. $row->City . ', ' . $row->State .' PreApproved On ' .$row->ApprovedDate . '</li>'; endwhile; mssql_close($dbhandle); ?> </div> I am following this tutorial here http://youtu.be/WrbaISEEihM. When i try to edit a product in my inventory i get an error "Undefined variable: product_list in /home/a7064593/public_html/storeadmin/inventory_edit.php on line 85" and i cant work out how to fix it. here is my code http://pastebin.com/k36tBjEL. Thanks I'm getting: Quote PHP Notice: Undefined variable: carttotal ... for this: $idtotal = $sizestotal + $sizemtotal + $sizeltotal + $sizexltotal; $carttotal += $idtotal; Why? Howdy Fairly new to the whole php scene made some php code which works, but i get the error Notice: Use of undefined constant Yes - assumed 'Yes' in C:\Program Files\EasyPHP-5.3.3\www\htdocs\top.php on line 26, line 26 is the first line code, kind of lost and would appreciate an explanation on how to fix this if possible thanks! Code: [Select] <?php if ($players['Banned'] == Yes){ echo $players['name'] ?> (BANNED) <?php } else {?> <a href="profile.php?id=<?php echo $players['id'] ?>"><?php echo $players['name'] ?> Hi, Getting this error message but I know that it is defined just for some reason it won't pick it up. Taken the url out so the site can't be accessed. An error occurred in script 'example/register.php' on line 101: Undefined variable: message Date/Time: 7-Feb-2011 18:32:10 Code: [Select] <?php # Script 16.6 - register.php // This is the registration page for the site. require_once("includes/functions.php"); include("includes/header.php"); require_once("includes/connection.php"); require_once ('includes/config.inc.php'); $page_title = 'Register'; //include ('includes/header.html'); if (isset($_POST['submitted'])) { // Handle the form. require_once ('mysqli_connect.php'); // Trim all the incoming data: $trimmed = array_map('trim', $_POST); // Assume invalid values: $fn = $ln = $e = $p = FALSE; // Check for a first name: if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['first_name'])) { $fn = mysqli_real_escape_string ($dbc, $trimmed['first_name']); } else { echo '<p class="error">Please enter your first name!</p>'; } // Check for a last name: if (preg_match ('/^[A-Z \'.-]{2,40}$/i', $trimmed['last_name'])) { $ln = mysqli_real_escape_string ($dbc, $trimmed['last_name']); } else { echo '<p class="error">Please enter your last name!</p>'; } // Check for an email address: if (preg_match ('/^[\w.-]+@[\w.-]+\.[A-Za-z]{2,6}$/', $trimmed['email'])) { $e = mysqli_real_escape_string ($dbc, $trimmed['email']); } else { echo '<p class="error">Please enter a valid email address!</p>'; } // Check for a password and match against the confirmed password: if (preg_match ('/^\w{4,20}$/', $trimmed['password1']) ) { if ($trimmed['password1'] == $trimmed['password2']) { $p = mysqli_real_escape_string ($dbc, $trimmed['password1']); } else { echo '<p class="error">Your password did not match the confirmed password!</p>'; } } else { echo '<p class="error">Please enter a valid password!</p>'; } if ($fn && $ln && $e && $p) { // If everything's OK... // Make sure the email address is available: $q = "SELECT user_id FROM users WHERE email='$e'"; $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); if (mysqli_num_rows($r) == 0) { // Available. // Create the activation code: $a = md5(uniqid(rand(), true)); // Add the user to the database: $q = "INSERT INTO users (email, pass, first_name, last_name, active, registration_date) VALUES ('$e', SHA1('$p'), '$fn', '$ln', '$a', NOW() )"; $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); if (mysqli_affected_rows($dbc) == 1) { // If it ran OK. // Send the email: $body = "Thank you for registering at. To activate your account, please click on this link:\n\n"; $body .= BASE_URL . 'activate.php?x=' . urlencode($e) . "&y=$a"; mail($trimmed['email'], 'Registration Confirmation', $body, 'From: '); // Finish the page: $message = '<h3>Thank you for registering! A confirmation email has been sent to your address. Please click on the link in that email in order to activate your account.</h3>'; } else { // If it did not run OK. echo '<p class="error">You could not be registered due to a system error. We apologize for any inconvenience.</p>'; } } else { // The email address is not available. echo '<p class="error">That email address has already been registered. If you have forgotten your password, use the link at right to have your password sent to you.</p>'; } } else { // If one of the data tests failed. echo '<p class="error">Please re-enter your passwords and try again.</p>'; } mysqli_close($dbc); } // End of the main Submit conditional. ?> <div id="content"> <div class="paddingContent"> <h3> Register </h3> <br /> <form action="register.php" method="post" class="contact"> <?php echo $message; ?> <div class="registerForm"> <label for="first_name" class="fixedwidth">First Name:</label> <input type="text" name="first_name" id="first_name" value="<?php if (isset($trimmed['first_name'])) echo $trimmed['first_name']; ?>"/> </div> <br /> <div class="registerForm"> <label for="last_name" class="fixedwidth">Last Name:</label> <input type="text" name="last_name" id="last_name" value="<?php if (isset($trimmed['last_name'])) echo $trimmed['last_name']; ?>"/> </div> <br /> <div class="registerForm"> <label for="email" class="fixedwidth">Email Address:</label> <input type="text" name="email" id="email"value="<?php if (isset($trimmed['email'])) echo $trimmed['email']; ?>" /> </div> <br /> <div class="registerForm"> <label for="password1" class="fixedwidth">Password</label> <input type="password" name="password1" id="password1" value="" /> <small>Use only letters, numbers, and the underscore. Must be between 4 and 20 characters long.</small> </div> <br /> <div class="registerForm"> <label for="password2" class="fixedwidth">Confirm Password:</label> <input type="password" name="password2" id="password"/> </div> <br /> <div class="submtForm"><input type="submit" name="submit" value="Register" /></div> <input type="hidden" name="submitted" value="TRUE" /> </form> </div> </div> <?php include("includes/footer.php"); ?> <?php // Include the HTML footer. //include ('includes/footer.html'); ?> I get an undefined constant error message. Am I using the variable correctly? Should I use an echo to output the variable as text? Added by <?php ${displayName}; ?> |