PHP - Anybody See Anything Wrong With This Code? Array Not Unsetting
so im developing a WEB GAME etc.... etc.... and im including a page that has functions on it in another page if that makes sense....<br>
so here's my code tell me why i cant get theese array values to clear? Code: [Select] function unlockables(){ // restore the content $unlockables = array( 'ach'=>array( // achevements unlockables md5(0)=>array('key'=>md5(0),'title'=>'novice','cash'=>'1000', 'exp'=>'100000', 'lvl'=>'20'), md5(1)=>array('key'=>md5(1),'title'=>'rookie','cash'=>'5000', 'exp'=>'150000', 'lvl'=>'40'), md5(2)=>array('key'=>md5(2),'title'=>'pro','cash'=>'10000', 'exp'=>'250000', 'lvl'=>'60'), md5(3)=>array('key'=>md5(3),'title'=>'king','cash'=>'50000', 'exp'=>'500000', 'lvl'=>'80'), md5(4)=>array('key'=>md5(4),'title'=>'Morphelo','cash'=>'100000','exp'=>'1000000','lvl'=>'100'), ), 'levels'=>array( // lvl up md5(5)=>array('key'=>md5(5),'price'=>'1000', 'lvlup'=>'1'), md5(6)=>array('key'=>md5(6),'price'=>'4000', 'lvlup'=>'5'), md5(7)=>array('key'=>md5(7),'price'=>'7500', 'lvlup'=>'10'), md5(8)=>array('key'=>md5(8),'price'=>'15000', 'lvlup'=>'25'), md5(9)=>array('key'=>md5(9),'price'=>'25000', 'lvlup'=>'50') ), 'exp'=>array( // exp up md5(10)=>array('key'=>md5(10),'price'=>'100','expup'=>'500'), md5(11)=>array('key'=>md5(11),'price'=>'1000','expup'=>'6000'), md5(12)=>array('key'=>md5(12),'price'=>'10000','expup'=>'75000'), md5(13)=>array('key'=>md5(13),'price'=>'50000','expup'=>'375000'), md5(14)=>array('key'=>md5(14),'price'=>'100000','expup'=>'750000') ) ); if($_COOKIE['lvl'] >= 0 && $_COOKIE['lvl'] < 20) { // first snakes $status = 'fs'; }elseif($_COOKIE['lvl'] >= 20 && $_COOKIE['lvl'] < 40){ // Novice $status = 'novice'; }elseif($_COOKIE['lvl'] >= 40 && $_COOKIE['lvl'] < 60){ // Rookie $status = 'rook'; }elseif($_COOKIE['lvl'] >= 60 && $_COOKIE['lvl'] < 80){ // pro $status = 'pro'; }elseif($_COOKIE['lvl'] >= 80 && $_COOKIE['lvl'] < 100){ // Novice $status = 'king'; }elseif($_COOKIE['lvl'] >= 100){ // Novice $status = 'morphelo'; } switch($status){ case 'novice': unset( $unlockables['ach'][md5(0)], $unlockables['ach'][md5(2)], $unlockables['ach'][md5(3)], $unlockables['ach'][md5(4)] ); break; case 'rook': unset( $unlockables['ach'][md5(0)], $unlockables['ach'][md5(1)], $unlockables['ach'][md5(3)], $unlockables['ach'][md5(4)] ); break; case 'pro': unset( $unlockables['ach'][md5(0)], $unlockables['ach'][md5(1)], $unlockables['ach'][md5(2)], $unlockables['ach'][md5(4)] ); break; case 'king': unset( $unlockables['ach'][md5(0)], $unlockables['ach'][md5(1)], $unlockables['ach'][md5(2)], $unlockables['ach'][md5(3)] ); break; case 'morphelo': unset($unlockables['ach']); break; } // here is were im trying print to screen but the array is still printing full print_r($unlockables['ach']); } Similar TutorialsI am using session variables to keep track of what is in a shopping cart. I can add the items to the cart quite easily enough. But my problem is that I can't delete a specific item in the cart. Below is a summary of what the array looks like $Item1=array("ProdID"=>"Hat","Color"=>"Not Needed","Size"=>5); $Item4=array("ProdID"=>"Shirt","Color"=>"Green","Size"=>"L"); $Item2=array("ProdID"=>"Pants","Color"=>"Not Needed","Size"=>"32x32"); $Item3=array("ProdID"=>"Socks","Color"=>"Not Needed","Size"=>"Not Needed"); $NumItems=4; $TestArray=array("NumItems"=>$NumItems,1=>$Item1,2=>$Item2,3=>$Item3,4=>$Item4); However when I attempt to delete any of the top level elements (1,2,3,4,NumItems), I either end up deleting only the last element (4) or somehow taking out 2 of them. I know that this must be an easy fix but I've looked at it for so long that I can't seem to figure out what the problem is. below is the code that I use to delete the Item from the array Code: [Select] $ItemNum=$_GET['item']; if ($ItemNum=="All"){ $ItemNum=$_GET['item']; if ($ItemNum=="All"){ unset($TestArray); unset($TestArray['NumItems']); unset($_SESSION['OrderTotal']); //header("Location:Cart.php?act=view"); } else{ $TestArray['NumItems']=$TestArray['NumItems']-1; if($TestArray['NumItems']<1) { unset($_SESSION['OrderTotal']); unset($TestArray); unset($TestArray['NumItems']); } else { unset($TestArray[$ItemNum]); } Can anyone take a look at this and point me in the correct direction? What I am after is to delete any element of the top array and keep the rest. As you can see, this array is setting each colorvalue to each idvalue. Code: [Select] <?php include("config.php"); include("db.php"); $arrid=$_POST['id']; $arrcolor=$_POST['color']; foreach ($arrid as $idvalue) { foreach ($arrcolor as $colorvalue) { $sql = "UPDATE colors SET color='$colorvalue' WHERE id = '$idvalue'"; mysql_query($sql) or die("Error: ".mysql_error()); echo $sql; } } header("Location: " . $config_basedir . "adminhome.php"); ?> I have a shopping cart, and I am using a php session to track the basket. All works fine, the only problem I have is completely removing the session once the order is placed. The user places the order, goes through the process and then once complete are sent back to a page called order complete. I have placed the following at the very top of this file: session_start(); session_unset(); session_destroy(); At first it looks as if the session is destroyed, but when I add an item to the basket it pulls up the item I previously ordered. Is the above the correct way? The session is only the sid? HI, I'm having trouble with unsetting a key from SESSION. I can unset the cart, but when I try to target the key, it doesn't work. Are there some regular things I should be looking for? The only thing I can think of is that I'm re-initializing the key by accident elsewhere in my code. if(isset($_POST['mainCartDelete'])){ unset($_SESSION['cart_array'][21]); $sessionArray = $_SESSION['cart_array']; print_r ($sessionArray); }Print_r returns Array ( [0] => Array ( [item_id] => 21 [quantity] => 1 ) ) Edited by 7blake, 10 December 2014 - 01:43 PM. I'm teaching myself a bit of OOP in php. found that i could pass an object into the SESSION array if i serialize() the object and then unserialize() it where i need it in other page files. all seems to work well until it comes time for a user to logout from my application and attempt to destroy the session. at times, when they log back in, this serialized SESSION value seems to still be set while other SESSION values have been cleared. at least i *thinnk* this is what is going on.
in my logout handler, i have the following:
$_SESSION = array(); // clear all SESSION vars setcookie(); // clear cookies session_destroy();but the above does not seem to be working. my guess is there is something native to serialized SESSION values that im not yet aware of. any help here would be much appreciated. Driving myself nuts...can't figure out what is wrong with this code. This is part of a pagination system that uses an array instead of hitting the db each time. I am using CodeLobster PHP version (3.7), Windows 7, and using a virtual server on my computer for development (XAMPP) the error I get is this: Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\website\searchinv.php on line 45 Warning: array_multisort() function.array-multisort: Argument #1 is expected to be an array or a sort flag in C:\xampp\htdocs\website\searchinv.php on line 49 Warning: array_slice() expects parameter 1 to be array, boolean given in C:\xampp\htdocs\website\searchinv.php on line 108 Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\website\searchinv.php on line 146 I am pasting the code below and point out each of the lines in the warnings above, and will try to clean up some so that it's not too extensive... Here is the problem: If I click on any of the "page" $_SESSION['rows'] has all the correct information contained in it. However, if I trigger the "re-sort" select option...$_SESSION['rows'] is empty...all my other $_SESSION variables are still there. At first I thought it was an issue with too many "if/ifelse/else" statements or a wrong syntax...so I changed it to a "switch" and traced it closely. I don't see anything wrong. Next I thought it was caused by the JavaScript "onchange" event...so I took that out...and replaced it with just a submit button...same result. I've done a search on the page for EVERY $_SESSION['rows'] and found only 4 and none of them should blank it out...I've been going crazy on this code for 2 days I'm pulling my hair out now...can ANYONE help? Code: [Select] if(!empty($_POST)) { if(empty($_POST['page'])) { switch($_POST) { case (!empty($_POST['ref'])): $deleted=sql_ending($_POST['del']); $rows=select_from_database('inventory', '*', 'ref_number=\''.$_POST['ref'].'\' and '.$deleted); break; case (!empty($_POST['type'])): $sort=$_POST['sort']; $deleted=sql_ending($_POST['del']); if($_POST['type']!='*') { $type=$_POST['type']; $len=strlen(trim($type)); if($len!=1) $type=$type.'-'; $end=$deleted.' and ref_number like \''.$type.'%\''; } else $end=$deleted; $rows=select_from_database('inventory', '*', $end, $sort); break; default: $data=$_SESSION['rows']; $sorts=explode(' ', $_POST['sort']); $keys=$sorts[0]; $order=$sorts[1]; Line 45 --> foreach ($data as $key => $row) { $column[$key]=$row[$keys]; } Line 49 --> $rows=array_multisort($column, $order, $data); break; } $_SESSION['rows']=$rows; } $x=count($_SESSION['rows']); if(isset($_SESSION['admin_user'])) $width=1280; else $width=900; $srch_rslt= ' <div id="displaybox"> <div id="translucent"></div> <div id="result" style="width:'.$width.'px;"> <!--[if lt IE 7]> <h3 class="center">This site looks much better with IE 7 and above. Please consider upgrading <a href="browsers.php">HERE</a>.</h3> <![endif]--> '; if($x==0) $srch_rslt.=' <h3>Search Result</h3> <a style="display: block; margin-right:10px;" href="searchinv.php" title="Close this box.">Close <img src="images/close.png" alt="Close this box." /></a> <p>We are sorry, but we currently do not have the equipment available for the given search. Please go back and <a href="searchinv.php" title="Search Again">search again</a>, or <a href="mailto:mywebsite@mywebsite.com" title="Send us an email so we can locate the equipment you need." onclick="popup(\'email.php?title=pray\', \'Request for Equipment\', 500, 500); return false">contact us</a> so we may begin to utilze are vast resources to locate your needs. </div> </div> '; else { if(empty($_POST['page'])) $pg=1; else $pg=$_POST['page']; $page=($pg-1)*20; $_SESSION['pages']=ceil($x/20); if(!$_SESSION['pages']>1) $buttons='<button type="button" class="active" title="Page 1">1</button> '; elseif($pg>1) { $prev_pg=$pg-1; $buttons='<button type="submit" class="button" title="First" value="1" name="page"><< First</button> <button type="submit" class="button" title="Previous" value="'.$prev_pg.'" name="page">< Prev</button> '; } for($i=1; $i<=$_SESSION['pages']; $i++) { if($i==$pg) $buttons.=' <button type="button" class="active" title="Page '.$pg.'">'.$pg.'</button> '; else $buttons.=' <button type="submit" class="button" title="Page '.$i.'" value="'.$i.'" name="page">'.$i.'</button> '; } if($pg<$_SESSION['pages']) { $next_pg=$pg+1; $buttons.=' <button type="submit" class="button" title="Next" value="'.$next_pg.'" name="page">Next ></button> <button type="submit" class="button" title="Last" value="'.$_SESSION['pages'].'" name="page">Last >></button> '; } Line 108 --> $results=array_slice($_SESSION['rows'], $page, 20, true); $srch_rslt.=' <h3>Search Complete!</h3> <a class="close" href="searchinv.php" title="Close this box.">Close <img style="border:none;" src="images/close.png" alt="Close this box." /></a> <p>You may now browse, re-sort and download your results in either PDF or an Excel format.</p> '; if (isset($_SESSION['admin_user'])) $table = 1260; else $table = 880; $tableinner = $table-20; $srch_rslt.=' <form name="search_page" method="post" action="searchinv.php?search='.$_POST['search'].'"> <div style="border:2px solid #00000; width:'.$table.'px;"> /* there's a table here */ '; $y=0; Line 146 --> foreach($results as $result) { $y++; $cl_type=explode('-', $result['ref_number']); $type=select_from_database('car_types', '*', 'abbvr=\''.$cl_type[0].'\''); $raw_notes=$result['notes']; if ($raw_notes == NULL) $notes="Call for additional information."; elseif (strlen($raw_notes) >65) { $txtlth=strpos($raw_notes, " ", 65); $notes=substr($raw_notes, 0, $txtlth).'<span id="para'.$pg.$y.'" class="jshide"> '.substr($raw_notes, $txtlth).'</span><a class="jsunhide" href="javascript:function(){};" onclick="toggleMe(\'para'.$pg.$y.'\', \'href'.$pg.$y.'\')" id="href'.$pg.$y.'" style="text-decoration: none">...[click for more]</a>'; } else $notes=$raw_notes; $srch_rslt.=' /*just some html output stuff */ $srch_rslt.=' </table> </div> <div> <input type="hidden" name="search" value="'.$_POST['search'].'" /> <p class="center"> '.$buttons.' </p> </div> </td> </tr> </table> </div> </form> <div class="search_menu_wrapper"> <ul class="sermenu"> <li>Need to search again? Back to the <a href="searchinv.php" title="Do another search.">search page</a>.</li> <li>Download this search to a <a href="http://www.mywebsitedowloadpdf.php?search='.$_POST['search'].'" title="Download to .pdf.">.pdf <img src="images/adobe.png" style="width:15px; height:15px; border:none;" alt="Download in Adobe PDF format." /></a></li> <li>Download this search to a <a href="http://www.mywebsitedowloadexcel.php?search='.$_POST['search'].'" title="Download to MS Excel.">MS Excel <img src="images/excel.png" style="width:15px; height:15px; border:none;" alt="Download in MS Excel format." /></a></li> </ul> </div> Like I said if I click a "page" button (stored in the $buttons var and printed above)...the code works beautifully...it's when the next lines (below) are triggered that cause $_SESSION['rows'] to be empty...I just don't get it Code: [Select] <div style="text-align:center;"> <form name="re_sort" method="post" action="searchinv.php?search='.$_POST['search'].'"> <label class="form-label-left" id="l_sort" for="sort">Re-Sort By:</label> <div class="form-input"> <select class="form-dropdown" style="width:190px" id="sort" name="sort" onchange="this.form.submit();"> <option value="ref_number SORT_ASC" selected="selected"> Reference Number - Ascending </option> <option value="ref_number SORT_DESC"> Reference Number - Descending </option> <option value="date_added SORT_ASC"> Date Added - Ascending </option> <option value="date_added SORT_DESC"> Date Added - Descending </option> <option value="last_update SORT_ASC"> Date Updated - Ascending </option> <option value="last_update SORT_DESC"> Date Updated - Descending </option> '; if($_SESSION['admin'] == 10) $srch_rslt.=' <option value="source SORT_ASC"> Source - Ascending </option> <option value="source SORT_DESC"> Source - Descending </option> '; $srch_rslt.=' </select><button type="submit" value="submit">Submit</button> </div> </form> </div> </div> </div> <script type="text/javascript" language="javascript"> //<![CDATA[ document.body.style.overflow="hidden"; //]]> </script> '; } } echo $srch_rslt; This topic has been moved to Application Frameworks. http://www.phpfreaks.com/forums/index.php?topic=353397.0 So I'm making a roster section for my clan's website. I have two tables, one for networks(PC, Xbox Live, etc) and another for games(CS: Source, Halo, etc). The games table is linked to the networks table so the games can be "grouped" by networks. And I put the word grouped in quotations because I'm not actually grouping them in the queries. I just run a query that gets the networks and in that loop I query the games table based on the networkID of the game row. I am trying to store this information in an array so I can pass it through to another file. The problem is within my array structure, because the page displays the correct results for the first network, but in the second network the games from the first network are displayed. I hope I explained that clearly enough. So here is my code: Code: [Select] $network_query = " SELECT * FROM ".DB_PREFIX."roster_networks ORDER BY title"; $network_query = mysql_query($network_query) or die(mysql_error()); if(mysql_num_rows($network_query) > 0){ while($network=mysql_fetch_assoc($network_query)){ $networks[$network['id']] = array( 'id' => $network['id'], 'title' => $network['title'] ); $games_query = " SELECT * FROM ".DB_PREFIX."roster_games WHERE networkID = ".$network['id']." ORDER BY title"; $games_query = mysql_query($games_query) or die(mysql_error()); if(mysql_num_rows($games_query) > 0){ while($game=mysql_fetch_assoc($games_query)){ $games[$game['id']] = array( 'id' => $game['id'], 'title' => $game['title'], 'icon' => '', 'record' => '', 'members' => '', 'status' => '' ); } } else { $games = array(); } $networks[$network['id']]['games'] = $games; } } else { $networks = array(); } I cannot figure out why this is happening. Anyone have any ideas? $handle = fopen("/etc/rpt.fifo", "r") or die("Unable to open file!"); $buffer = trim(fgets($handle)); $ary = explode (",", $buffer); $x = $ary[2]; print $x; flush(); pclose($handle); When I run it, it reports: Notice: Undefined offset: 2 on line 4 This is the line in /etc/rpt.fifo that is being read (there are 4 indices) 20210721153256,1100,TXKEY,89790 The error makes no sense to me but I'm no expert <g> Edited July 21 by KenHorseGood day all, I have this change password code and it works well when all the parameters are ok, like username correct and email correct. But when I test it to see the result if the wrong username or email is entered the else statement doesnt run, not even an error, just skips the code and shows the other parts of the page, just as if the code did not run. Here is the code: <?php include("mysql_connect.php"); $username=$_POST['username']; $email=$_POST['email']; $newpassword=$_POST['newpassword']; $confirm_newpassword=$_POST['confirm_newpassword']; $query = "SELECT * FROM users WHERE username='$username' AND email='$email'"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ if ($username == $row["username"] && $email == $row["email"]){ echo "<center><h1>Thank you " . $row["firstname"] ." ". $row["surname"] .". Your password has been changed.<br/> An email has also been sent to $email with the details of the new password.</h1></center>"; $sql="UPDATE users SET password = '$newpassword', password_confirm='$confirm_newpassword' WHERE (id = $row[id])"; $update = mysql_query($sql) or die(mysql_error()); $to = $row["email"]; $subject = "Your password change at My Site"; $message = "Dear " . $row["firstname"] ." ". $row["surname"] .",\r\rYour Password Change has been completed successfully.\r\rYour New Password is:\r". $row["password"] .".\r\rPlease guard this Password carefully.\r\rRegards,\rAdmin - My Site"; require_once "class.phpmailer.php"; $mail = new PHPMailer(); $mail->IsSendmail(); $mail->SetFrom('admin@mysite.com', 'Admin - My Site'); $mail->AddAddress($to); $mail->Subject = $subject; $mail->Body = $message; $mail->Send(); } else{ echo"<center><h1>Invalid username and/or email.<br/>Please go back to the <a href=\"password_recovery.php\">Password Change Request</a> page and enter correct details.</h1></center>"; } } ?> Can anyone see what is wrong with this code? I get the following parse error: syntax error, unexpected $end Code: [Select] if(isSet($_GET['answer'])) { $answ = $_GET['answer']; $nextanswer=$answ+1;} else{} $counter2 = 1; while ($counter2 <= $answ): echo $Answer[$counter2]."<br>"; $counter2++; endwhile; if($nextansw>0){ if(isset($Answer[$nextanswer])){ echo "<a href=\"/Code-sandbox.php?sid=".$name."&answer=".$nextanswer."\">next</a>";} else{echo "End of questions<br>";} else{} Sorry for the amount of code below this is one full page. Ok, when I try to login to the member section it wont let me. I can succesfully register and have made sure that the data is there in MySQL. Every time I try to login the page just refreshes. Oh and I am new here. I think it has something to do with the (header("Location: http://www.PureReactionUK.com/member.php/"); exit;)? I could be wrong. Here is my code: Code: [Select] <?php session_start(); include 'config.php'; if(isset($_POST['login'])) { $username = trim(addslashes($_POST['username'])); $password = md5(trim($_POST['password'])); $query = mysql_query("SELECT * FROM Users WHERE Username = '$username' AND Password = '$password' LIMIT 1") or die(mysql_error()); $row = mysql_fetch_array($query); if(mysql_num_rows($query) > 0) { if($row['Activated'] > 0) { $_SESSION['s_logged_n'] = 'true'; $_SESSION['s_username'] = $username; $_SESSION['s_name'] = $row['Name']; header("Location: http://www.PureReactionUK.com/member.php/"); exit; } else { echo ' <!DOCTYPE HTML> <html> <head> <title>PureReactionUK - Home</title> <link rel="shortcut icon" href="images/favicon.ico"> <meta name="description" content="Here you will find a tone of things that you will find very helpfull." /> <meta name="keywords" content="Pure,Reaction,UK,HD,BD,x,Brutal,Democracy,iPad,iPhone,iPod,Theme,WinetrBoard,iOS,Hack,Mod,Cydia,Surik,Apple,Game,Apps,USB,Fix,Restore,Design,SummerBoard,Playstation,3,Xbox,360,MineCraft,Server,Call,Of,Duty,Modern,Warfare,2,3,4,5,6,7,8,9,Black,Ops,Icons,Zombies,Jtag,SSH,iFile,HTML,Jailbreak,CSS,Javascript,Craig,Stewart,YouTube,Music,Downloads,Servers,Bukkit,MCAdmin,Tiny,Umbrella,GreenpoisOn,SpringBoard,Windows,Microsoft,XP,Vista" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" type="text/css" href="css/style.css" /> <script src="javascript/rollover.js" type="text/javascript"></script> <style type="text/css"> body,td,th { font-family: "trebuchet ms", arial, sans-serif; font-size: 0.8em; } a:link { color: #09F; } </style> </head> <body> <div id="main"> <div id="header"> <div id="logo"> <div id="logo_text"> <h1><a href="index.html">PureReaction<span class="logo_colour">UK</span></a></h1> <h2>All You Need To Know Is Here, Have A Look</h2> </div> </div> <div id="menubar"> <ul id="menu"> <li class="selected"><a href="index.html" title="Home" target="_self">Home</a></li> <li><a href="tutorials.html" title="Tutorials" target="_self">Tutorials</a></li> <li><a href="downloads.html" title="Downloads" target="_self">Downloads</a></li> <li><a href="register.html" title="Register" target="_self">Register</a></li> <li><a href="login.html" title="Log In" target="_self">Log In</a></li> </ul> </div> </div> <div id="content_header"></div> <div id="site_content"> <div class="sidebar"> <h3>Latest Updates</h3> <h4> Website Launched</h4> <h5>January 1st, 2010</h5> <p>Take a good look around and take your time there is alot of content to explore. <br /> <a href="index.html" title="Home" target="_self">Read more</a></p> <p></p> <h4>New Downloads</h4> <h5>January 1st, 2010</h5> <p>Check out the latest downloads by clicking the link below. Remember you must sign up / sign in.<br /> <a href="downloads.html" title="Downloads" target="_self">Read more</a></p> <h3>Useful Links</h3> <ul> <li><a href="http://www.minecraft.net/" title="MineCraft" target="_blank">MineCraft</a></li> <li><a href="http://modmyi.com/" title="ModMyi" target="_blank">ModMyi</a></li> <li><a href="http://www.ifans.com/" title="iFans" target="_blank">iFans</a> <ul> <li><a href="http://www.minecraftforum.net/" title="MineCraft Forum" target="_blank">MineCraft - Forum</a></li> </ul> </li> </ul> </div> <div id="content"> <h1>Log In Here</h1><div id="error"><p>Sorry, you must activate your account first. Please check your email for the email.</p> <p>Didn'."'".'t get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p></div> </p> </div> </div> <div id="content_footer"></div> <div id="footer"> Copyright © All Rights Reserved By <a href="http://www.purereactionuk.com/" title="PureReactionUK" target="_self">www.PureReactionuk.com</a> - 2011</div> </div> </body> </html> '; } } else { echo ' <html> <head> <title>PureReactionUK - Home</title> <link rel="shortcut icon" href="images/favicon.ico"> <meta name="description" content="Here you will find a tone of things that you will find very helpfull." /> <meta name="keywords" content="Pure,Reaction,UK,HD,BD,x,Brutal,Democracy,iPad,iPhone,iPod,Theme,WinetrBoard,iOS,Hack,Mod,Cydia,Surik,Apple,Game,Apps,USB,Fix,Restore,Design,SummerBoard,Playstation,3,Xbox,360,MineCraft,Server,Call,Of,Duty,Modern,Warfare,2,3,4,5,6,7,8,9,Black,Ops,Icons,Zombies,Jtag,SSH,iFile,HTML,Jailbreak,CSS,Javascript,Craig,Stewart,YouTube,Music,Downloads,Servers,Bukkit,MCAdmin,Tiny,Umbrella,GreenpoisOn,SpringBoard,Windows,Microsoft,XP,Vista" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" type="text/css" href="css/style.css" /> <script src="javascript/rollover.js" type="text/javascript"></script> <style type="text/css"> body,td,th { font-family: "trebuchet ms", arial, sans-serif; font-size: 0.8em; } a:link { color: #09F; } </style> </head> <body> <div id="main"> <div id="header"> <div id="logo"> <div id="logo_text"> <h1><a href="index.html">PureReaction<span class="logo_colour">UK</span></a></h1> <h2>All You Need To Know Is Here, Have A Look</h2> </div> </div> <div id="menubar"> <ul id="menu"> <li class="selected"><a href="index.html" title="Home" target="_self">Home</a></li> <li><a href="tutorials.html" title="Tutorials" target="_self">Tutorials</a></li> <li><a href="downloads.html" title="Downloads" target="_self">Downloads</a></li> <li><a href="register.html" title="Register" target="_self">Register</a></li> <li><a href="login.html" title="Log In" target="_self">Log In</a></li> </ul> </div> </div> <div id="content_header"></div> <div id="site_content"> <div class="sidebar"> <h3>Latest Updates</h3> <h4> Website Launched</h4> <h5>January 1st, 2010</h5> <p>Take a good look around and take your time there is alot of content to explore. <br /> <a href="index.html" title="Home" target="_self">Read more</a></p> <p></p> <h4>New Downloads</h4> <h5>January 1st, 2010</h5> <p>Check out the latest downloads by clicking the link below. Remember you must sign up / sign in.<br /> <a href="downloads.html" title="Downloads" target="_self">Read more</a></p> <h3>Useful Links</h3> <ul> <li><a href="http://www.minecraft.net/" title="MineCraft" target="_blank">MineCraft</a></li> <li><a href="http://modmyi.com/" title="ModMyi" target="_blank">ModMyi</a></li> <li><a href="http://www.ifans.com/" title="iFans" target="_blank">iFans</a> <ul> <li><a href="http://www.minecraftforum.net/" title="MineCraft Forum" target="_blank">MineCraft - Forum</a></li> </ul> </li> </ul> </div> <div id="content"> <h1>Log In Here</h1><div id="error"><p>There was an error processing your login, it appears that your username and/or password was incorrect. Please try again.</p> <p>Didn'."'".'t get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p> </div> </div> <div id="content_footer"></div> <div id="footer"> Copyright © All Rights Reserved By <a href="http://www.purereactionuk.com/" title="PureReactionUK" target="_self">www.PureReactionuk.com</a> - 2011</div> </div> </body> </html> '; } } else { ?> <html> <head> <title>PureReactionUK - Home</title> <link rel="shortcut icon" href="images/favicon.ico"> <meta name="description" content="Here you will find a tone of things that you will find very helpfull." /> <meta name="keywords" content="Pure,Reaction,UK,HD,BD,x,Brutal,Democracy,iPad,iPhone,iPod,Theme,WinetrBoard,iOS,Hack,Mod,Cydia,Surik,Apple,Game,Apps,USB,Fix,Restore,Design,SummerBoard,Playstation,3,Xbox,360,MineCraft,Server,Call,Of,Duty,Modern,Warfare,2,3,4,5,6,7,8,9,Black,Ops,Icons,Zombies,Jtag,SSH,iFile,HTML,Jailbreak,CSS,Javascript,Craig,Stewart,YouTube,Music,Downloads,Servers,Bukkit,MCAdmin,Tiny,Umbrella,GreenpoisOn,SpringBoard,Windows,Microsoft,XP,Vista" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" type="text/css" href="css/style.css" /> <script src="javascript/rollover.js" type="text/javascript"></script> <style type="text/css"> body,td,th { font-family: "trebuchet ms", arial, sans-serif; font-size: 0.8em; } a:link { color: #09F; } </style> </head> <body> <div id="main"> <div id="header"> <div id="logo"> <div id="logo_text"> <h1><a href="index.html">PureReaction<span class="logo_colour">UK</span></a></h1> <h2>All You Need To Know Is Here, Have A Look</h2> </div> </div> <div id="menubar"> <ul id="menu"> <li class="selected"><a href="index.html" title="Home" target="_self">Home</a></li> <li><a href="tutorials.html" title="Tutorials" target="_self">Tutorials</a></li> <li><a href="downloads.html" title="Downloads" target="_self">Downloads</a></li> <li><a href="register.php" title="Register" target="_self">Register</a></li> <li><a href="login.php" title="Log In" target="_self">Log In</a></li> </ul> </div> </div> <div id="content_header"></div> <div id="site_content"> <div class="sidebar"> <h3>Latest Updates</h3> <h4> Website Launched</h4> <h5>January 1st, 2010</h5> <p>Take a good look around and take your time there is alot of content to explore. <br /> <a href="index.html" title="Home" target="_self">Read more</a></p> <p></p> <h4>New Downloads</h4> <h5>January 1st, 2010</h5> <p>Check out the latest downloads by clicking the link below. Remember you must sign up / sign in.<br /> <a href="downloads.html" title="Downloads" target="_self">Read more</a></p> <h3>Useful Links</h3> <ul> <li><a href="http://www.minecraft.net/" title="MineCraft" target="_blank">MineCraft</a></li> <li><a href="http://modmyi.com/" title="ModMyi" target="_blank">ModMyi</a></li> <li><a href="http://www.ifans.com/" title="iFans" target="_blank">iFans</a> <ul> <li><a href="http://www.minecraftforum.net/" title="MineCraft Forum" target="_blank">MineCraft - Forum</a></li> </ul> </li> </ul> </div> <div id="content"> <h1>Log In Here</h1><form name="login_now" method="post" action="<?= $_SERVER['PHP_SELF'] ?>"> <table width="589" border="0"> <tr> <td width="116">Username</td> <td width="258"><label for="username"></label> <input type="text" name="username" id="username"></td> <td width="201"> </td> </tr> <tr> <td>Password</td> <td><label for="date"></label> <input type="password" name="password" id="password"> <label for="date"></label></td> <td> </td> </tr> <tr> <td> </td> <td><input type="submit" name="submit" id="submit" value="Submit"> <input type="reset" name="reset" id="reset" value="Reset"></td> <td> </td> </tr> </table> </form> <p>Didn't get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p> <p>Need an account? <a href="register.php">Click here</a> to register, it's completely free! </p> </p> </div> </div> <div id="content_footer"></div> <div id="footer"> Copyright © All Rights Reserved By <a href="http://www.purereactionuk.com/" title="PureReactionUK" target="_self">www.PureReactionuk.com</a> - 2011</div> </div> </body> </html> <? } mysql_close($l); ?> <?php global $con; $name = $_GET['name']; $email = $_GET['email']; if((!empty($name)) && (!empty($email))){ $check = $con->prepare('SELECT email FROM subs WHERE email = ?'); $check->execute([$email]); $row = $check->fetch(); if($email == $row['email']){ echo '<span>'.$email.' already in database, try another email!.</span>'; }else{ $subscribe = $con->prepare('INSERT INTO subs (name, email) VALUES (?, ?)'); $subscribe->execute([$name, $email]); if($subscribe){ echo '<span>Hi '.$name.'</b>,subscription is now active.</span>'; }else{ echo '<span>Try again</span>'; } } }else{ echo '<span>please enter something</span>'; } ?> the problem found at if($subscribe){ //the echo not showing the span element when data is inserted }
any help please? Edited November 14, 2019 by cyberRobotadded code indents Ive made this code: Code: [Select] <?php $button = $_GET['submit']; $search = $_GET['search']; $s = $_GET['s']; if (!$s) $s = 0; $e = 10; $next = $s + $e; $prev = $s - $e; if (strlen($search)<=2) echo "Must be greater then 3 chars"; else { echo "<br /><table><tr><td><img src='juzzy.jpg' /></td><td><form action='search.php' method='GET'><input type='text' onclick=value='' size='50' name='search' value='$search'> <input type='submit' name='submit' value='Search'></form></td></tr></table>"; mysql_connect("localhost","*********","*******"); mysql_select_db("************"); $search_exploded = explode(" ",$search); foreach($search_exploded as $search_each) { $x++; if ($x==1) $construct .= "keywords LIKE '%$search_each%'"; else $construct .= " OR keywords LIKE '%$search_each%'"; } $constructx = "SELECT * FROM searchengine WHERE $construct"; $construct = "SELECT * FROM searchengine WHERE $construct LIMIT $s,$e"; $run = mysql_query($constructx); $foundnum = mysql_num_rows($run); //here is the thing which is causing the error. $run_two = mysql_query("$construct"); if ($foundnum==0) echo "No results found for <b>$search</b>"; else { echo "<table bgcolor='#0000FF' width='100%' height='1px'><br /></table><table bgcolor='#f0f7f9' width='100%' height='10px'><tr><td><div align='right'>Showing 1-10 of <b>$foundnum</b> results found for <b>$search.</b></div></td></tr></table><p>"; while ($runrows = mysql_fetch_assoc($run_two)) { $title = $runrows['title']; $desc = $runrows['description']; $url = $runrows['url']; echo "<table width='300px'> <h4><a href='http://$url'><b>$title</b></a><br /> $desc<br> <font color='00CC00'>$url</font></table></h4> "; } ?> <table width='100%'> <tr> <td> <div align="left"> <?php if (!$s<=0) echo "<a href='search.php?search=$search&s=$prev'>Prev</a>"; $i =1; for ($x=0;$x<$foundnum;$x=$x+$e) { echo " <a href='search.php?search=$search&s=$x'>$i</a> "; $i++; } if ($s<$foundnum-$e) echo "<a href='search.php?search=$search&s=$next'>Next</a>"; } } ?> </div> </td> </tr> </table> And when ive uploaded it to the host and tryed to search using it (this is just the main code, not the index code) it comes up with this one error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/seanhall/public_html/Search/search.php on line 54 here is code: Code: [Select] <?php session_start(); // Must start session first thing /* Created By Adam Khoury @ www.flashbuilding.com -----------------------June 20, 2008----------------------- */ // Here we run a login check if (!isset($_SESSION['id'])) { echo 'Please <a href="login.php">log in</a> to access your account'; exit(); } //Connect to the database through our include include_once "connect_to_mysql.php"; // Place Session variable 'id' into local variable $userid = $_SESSION['id']; // Query member data from the database and ready it for display $sql = mysql_query("SELECT * FROM members WHERE userid='$userid' LIMIT 1"); while($row = mysql_fetch_array($sql)){ $name = $row["name"]; $phone = $row["phone"]; $username = $row["username"]; $address = $row["address"]; $city = $row["city"]; $state = $row["state"]; $zip = $row["zip"]; $cell = $row["cell"]; $email = $row["email"]; $accounttype = $row["accounttype"]; $rank = $row["rank"]; $badges = $row["badges"]; } // Set error message as blank upon arrival to page $errorMsg = ""; // First we check to see if the form has been submitted if (isset($_POST['username'])){ $name = ereg_replace("[^A-Z a-z0-9]", "", $_POST['name']); // filter everything but numbers and letters $phone = ereg_replace("[^A-Z a-z0-9]", "", $_POST['phone']); // filter everything but spaces, numbers, and letters $username = ereg_replace("[^A-Z a-z0-9]", "", $_POST['username']); // filter everything but spaces, numbers, and letters $address = ereg_replace("[^A-Z a-z0-9]", "", $_POST['address']); // filter everything but spaces, numbers, and letters $city = ereg_replace("[^A-Za-z0-9]", "", $_POST['city']); // filter everything but lowercase letters $state = ereg_replace("[^A-Za-z0-9]", "", $_POST['state']); // filter everything but lowercase letters $zip = ereg_replace("[^A-Za-z0-9]", "", $_POST['zip']); // filter everything but lowercase letters $cell = ereg_replace("[^A-Za-z0-9]", "", $_POST['cell']); // filter everything but lowercase letters $email = stripslashes($_POST['email']); $email = strip_tags($email); $email = mysql_real_escape_string($email); if((!$email)){ $errorMsg = "You did not submit the following required information!<br /><br />"; if(!$email){ $errorMsg .= "--- Email Address"; } } else { $sql = mysql_query("INSERT INTO events (name, phone, username, address, city, state, zip, cell, email) VALUES('$name','$phone','$username','$address','$city','$state','$zip','$cell','$email") or die (mysql_error()); $to = "$email"; // Change this to your site admin email $from = "events@final.net46.net"; $subject = "Complete your registration"; //Begin HTML Email Message where you need to change the activation URL inside $message = '<html> <body bgcolor="#FFFFFF"> Hi ' . $username . ', <br /><br /> You must complete this step to activate your account with us. <br /><br /> Please click here to activate now >> <a href="http://www.somewebsite.com/activation.php?id=' . $id . '"> ACTIVATE NOW</a> <br /><br /> Your Login Data is as follows: <br /><br /> E-mail Address: ' . $email . ' <br /> Password: ' . $password . ' <br /><br /> Thanks! </body> </html>'; // end of message $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; $to = "$to"; // Finally send the activation email to the member mail($to, $subject, $message, $headers); // Then print a message to the browser for the joiner print "<br /><br /><br /><h4>OK $firstname, one last step to verify your email identity:</h4><br /> We just sent an Activation link to: $email<br /><br /> <strong><font color=\"#990000\">Please check your email inbox in a moment</font></strong> to click on the Activation <br /> Link inside the message. After email activation you can log in."; exit(); // Exit so the form and page does not display, just this success message } // Close else after database duplicate field value checks } // Close else after missing vars check //Close if $_POST ?> <?php // if no id is specified, list the available articles if(!isset($_GET['eventid'])) { $self = $_SERVER['PHP_SELF']; $query = "SELECT eventid, event FROM Registration ORDER BY eventid"; $result = mysql_query($query) or die('Error : ' . mysql_error()); // create the article list $description = '<ol>'; while($row = mysql_fetch_array($result, MYSQL_NUM)) { list($eventid, $event, $date) = $row; $description .= "<li><a href=\"$self?eventid=$eventid\">$event</a></li>\r\n"; } $description .= '</ol>'; $Events = 'Events'; } else { // get the article info from database $query = "SELECT event, description, startdate, enddate location, subevent1, subevent2, subevent3, subevent4, subevent5, subevent6, subevent7, subevent8, price1, price2, price3, price4, price5, price6, price7, price8 FROM Registration WHERE eventid=".$_GET['eventid']; $result = mysql_query($query) or die('Error : ' . mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); $event = $row['event']; $description = $row['description']; $startdate = $row['startdate']; $enddate = $row['enddate']; $location = $row['location']; $subevent1 = $row['subevent1']; $subevent2 = $row['subevent2']; $subevent3 = $row['subevent3']; $subevent4 = $row['subevent4']; $subevent5 = $row['subevent5']; $subevent6 = $row['subevent6']; $subevent7 = $row['subevent7']; $subevent8 = $row['subevent8']; $price1 = $row['price1']; $price2 = $row['price2']; $price3 = $row['price3']; $price4 = $row['price4']; $price5 = $row['price5']; $price6 = $row['price6']; $price7 = $row['price7']; $price8 = $row['price8']; } ?> <!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" /> <title>Register</title> <style type="text/css"> #apDiv1 { position:absolute; left:33px; top:320px; width:252px; height:48px; z-index:1; } #apDiv2 { position:absolute; left:33px; top:361px; width:254px; height:46px; z-index:2; } #apDiv3 { position:absolute; left:33px; top:525px; width:256px; height:43px; z-index:3; } #apDiv4 { position:absolute; left:33px; top:402px; width:250px; height:48px; z-index:4; } #apDiv5 { position:absolute; left:106px; top:616px; width:263px; height:255px; z-index:5; } #apDiv6 { position:absolute; left:323px; top:200px; width:898px; height:530px; z-index:5; } #apDiv7 { position:absolute; left:33px; top:443px; width:266px; height:42px; z-index:6; } #apDiv8 { position:absolute; left:111px; top:500px; width:125px; height:37px; z-index:7; } #apDiv8 strong { font-size: 24px; } #apDiv9 { position:absolute; left:33px; top:408px; width:267px; height:49px; z-index:8; } #apDiv10 { position:absolute; left:33px; top:449px; width:242px; height:23px; z-index:9; } #apDiv8 a { color: #000; } #apDiv11 { position:absolute; left:101px; top:490px; width:168px; height:42px; z-index:10; font-size: 24px; font-weight: bold; } #apDiv11 a { color: #000; } #apDiv12 { position:absolute; left:33px; top:210px; width:205px; height:107px; z-index:11; } #apDiv12 { text-align: center; } #apDiv13 { position:absolute; left:33px; top:320px; width:248px; height:47px; z-index:12; } #apDiv { position:absolute; left:33px; top:484px; width:225px; height:35px; z-index:11; } #apDiv14 { position:absolute; left:33px; top:566px; width:298px; height:51px; z-index:12; } #apDiv15 { position:absolute; left:101px; top:611px; width:168px; height:42px; z-index:10; font-size: 24px; font-weight: bold; } #apDiv5 a { font-size: 24px; color: #000; font-weight: bold; } #apDiv23 table tr td1 { font-size: 14px; } </style> <script type="text/javascript"> function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } </script> <style type="text/css"> #apDiv6 #form1 table tr th { text-align: center; } #apDiv6 table tr td table tr td { text-align: center; } #apDiv16 { position:absolute; left:330px; top:45px; width:208px; height:100px; z-index:13; } #apDiv6 table tr td #apDiv16 table tr th { font-size: 36px; } #apDiv17 { position:absolute; left:183px; top:342px; width:427px; height:65px; z-index:13; } #apDiv6 table tr td #Accordion1 .AccordionPanel.AccordionPanelOpen .AccordionPanelContent #apDiv17 table tr th { color: #999; } </style> <style type="text/css"> #apDiv19 { position:absolute; left:33px; top:320px; width:271px; height:33px; z-index:13; } #apDiv20 { position:absolute; left:578px; top:368px; width:157px; height:87px; z-index:14; } #apDiv21 { position:absolute; left:8px; top:705px; width:270px; height:683px; z-index:15; } #apDiv22 { position:absolute; left:476px; top:313px; width:596px; height:124px; z-index:16; } #apDiv6 table tr td table tr th { text-align: left; } #apDiv23 { position:absolute; left:626px; top:250px; width:247px; height:85px; z-index:16; text-align: center; font-size: 36px; } #apDiv23 table tr td { text-align: center; font-size: 24px; } #apDiv24 { position:absolute; left:626px; top:295px; width:247px; height:63px; z-index:17; text-align: center; font-size: 20px; } .klgjsa { font-size: 18px; } #apDiv24 { font-size: 16px; } #apDiv24 { font-size: 18px; } #apDiv24 { color: #C90; } </style> </head> <body onload="MM_preloadImages('button/pictures2.png','button/projects1.png','button/news2.png','button/eventmanager2.png','button/membermanager2.png','button/newsmanager2.png','button/myprofile2.png')"> <div id="apDiv6"> <table width="600" border="0" align="center" cellpadding="10" cellspacing="1" bgcolor="#336699"> <tr> <td bgcolor="#FFFFFF"><h1 align="center"><?php echo $Events; ?></h1> <p> </p> <p> </p> <p><?php echo $description; ?></p> <p> </p> <p> </p> <?php $sql = mysql_query("SELECT * FROM members WHERE userid='$userid' LIMIT 1"); while($row = mysql_fetch_array($sql)){ $name = $row["name"]; $phone = $row["phone"]; $address = $row["address"]; $city = $row["city"]; $state = $row["state"]; $zip = $row["zip"]; $cell = $row["cell"]; $email = $row["email"]; } $sql = mysql_query("SELECT * FROM Registration WHERE eventid=".$_GET['eventid']." LIMIT 1"); while($row = mysql_fetch_array($sql)){ $event= $row["event"]; $subevent1 = $row['subevent1']; $subevent2 = $row['subevent2']; $subevent3 = $row['subevent3']; $subevent4 = $row['subevent4']; $subevent5 = $row['subevent5']; $subevent6 = $row['subevent6']; $subevent7 = $row['subevent7']; $subevent8 = $row['subevent8']; $price1 = $row['price1']; $price2 = $row['price2']; $price3 = $row['price3']; $price4 = $row['price4']; $price5 = $row['price5']; $price6 = $row['price6']; $price7 = $row['price7']; $price8 = $row['price8']; } ?> <?php // when displaying an article show a link // to see the article list if(isset($_GET['eventid'])) { ?> <div id="jQueryUIAccordion"> <h3> </h3> <div> <p> <table width="575" border="0" cellspacing="2" cellpadding="2"> <tr> <th width="563" bgcolor="#999999" scope="col">Location</th> </tr> </table> <table width="574" height="16" border="0" cellpadding="2" cellspacing="2"> <tr> <th height="12" scope="col"><?php echo $location; ?></th> </tr> </table> <table width="573" border="0" cellspacing="2" cellpadding="2"> <tr> <th width="561" bgcolor="#999999" scope="col">Description</th> </tr> </table> <table width="576" border="0" cellspacing="2" cellpadding="2"> <tr> <th width="564" height="11" scope="col"><?php echo $title1; ?><br /><?php echo $price1; ?></th> <th width="564" scope="col"><?php echo $subevent1; ?></th> </tr> <tr> <th height="11" scope="col"><?php echo $title2; ?><br /><?php echo $price2; ?></th> <th scope="col"><?php echo $subevent2; ?> </th> </tr> <tr> <th height="11" scope="col"><?php echo $title3; ?><br /><?php echo $price3; ?></th> <th scope="col"><?php echo $subevent3; ?></th> </tr> <tr> <th height="11" scope="col"><?php echo $title4; ?><br /><?php echo $price4; ?></th> <th scope="col"><?php echo $subevent4; ?></th> </tr> <tr> <th height="11" scope="col"><?php echo $title5; ?><br /><?php echo $price5; ?></th> <th scope="col"><?php echo $subevent5; ?></th> </tr> <tr> <th height="11" scope="col"><?php echo $title6; ?><br /><?php echo $price6; ?></th> <th scope="col"><?php echo $subevent6; ?></th> </tr> <tr> <th height="11" scope="col"><?php echo $title7; ?><br /><?php echo $price7; ?></th> <th scope="col"><?php echo $subevent7; ?></th> </tr> <tr> <th height="11" scope="col"><?php echo $title8; ?><br /><?php echo $price8; ?></th> <th scope="col"><?php echo $subevent8; ?></th> </tr> </table> <hr /> <table width="200" border="0" cellspacing="2" cellpadding="2"> <tr> <th scope="col">Price:</th> </tr> </table> <table width="200" border="0" cellspacing="2" cellpadding="2"> <tr> <th scope="col">$<?php echo $price; ?></th> </tr> </table> </p> <?php if (isset($_GET['eventid'])) { include('connect1.php'); $sql = mysql_query("SELECT * FROM Registration WHERE eventid='$eventid' LIMIT 1"); while($row = mysql_fetch_array($sql)){ $eventid = $row["eventid"]; $event = $row["event"]; $date = $row["date"]; $description = $row["description"]; $location = $row["location"]; } $result = mysqli_query($dbcon, $query) or die('error getting data'); echo "<table>"; while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo "<tr><td>"; echo "<a href=\"registration.php?eventid=".$_GET['eventid']."\"><ul>Register Now!</ul></a>"; echo "</td></tr>"; } echo "</table>"; } ?> <div id="apDiv18"></div> <p align="center"><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Back to Events</a></p> <?php } ?></td></tr> </table> </div><div id="apDiv2"><a href="register.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image3','','button/register2.png',1)"><img src="button/register1.png" name="Image3" width="235" height="50" border="0" id="Image3" /></a></div> <div id="apDiv4"><a href="projects.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image4','','button/projects2.png',1)"><img src="button/projects1.png" name="Image4" width="235" height="50" border="0" id="Image4" /></a></div> <div id="apDiv11"><?php if ($accounttype == "Scout") { echo '<a href="../logout.php">Logout</a>';} ?></div> <div id="apDiv12"><?php echo "$accounttype"; ?> <p><?php echo "$name"; ?></p> <p>Troop 78</p> </div> <div id="apDiv5"><?php if ($accounttype == "Admin") { echo "<a href=\"../logout.php\">Logout</a>"; } ?></div> <div id="apDiv7"><a href="news.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image6','','button/news2.png',1)"><img src="button/news1.png" name="Image6" width="235" height="50" border="0" id="Image6" /></a></div> <div id="apDiv"> <?php if ($accounttype == "Admin") { echo "<a href=\"../search1.php\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('Image7','','../button/membermanager2.png',1)\"><img src=\"../button/membermanager1.png\" name=\"Image7\" width=\"235\" height=\"50\" border=\"0\" id=\"Image7\" /></a>"; } ?></div> <div id="apDiv3"><?php if ($accounttype == "Admin") { echo "<a href=\"../eventmanager.php\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('Image8','','../button/eventmanager2.png',1)\"><img src=\"../button/eventmanager1.png\" name=\"Image8\" width=\"235\" height=\"50\" border=\"0\" id=\"Image8\" /></a>"; } ?> </div> <div id="apDiv14"><?php if ($accounttype == "Admin") { echo "<a href=\"../newsmanager.php\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('Image9','','../button/newsmanager2.png',1)\"><img src=\"../button/newsmanager1.png\" name=\"Image9\" width=\"235\" height=\"50\" border=\"0\" id=\"Image9\" /></a>"; } ?> </div> <div id="apDiv19"><a href="myprofile.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image5','','button/myprofile2.png',1)"><img src="button/myprofile1.png" name="Image5" width="235" height="50" border="0" id="Image5" /></a></div> <div id="apDiv21"><img src="button/red.png" width="282" height="687" /></div> <div id="apDiv23"><?php echo $event; ?> <br /> </div> <div id="apDiv24"><?php echo $startdate;?> <span class="klgjsa">-</span> <?php echo $enddate; ?></div> <img name="boyscout" src="buttons/boyscout.jpg" width="1180" height="700" border="0" id="boyscout" alt="" /> </body> </html> here is error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/a6254834/public_html/register.php on line 469 help? Code: [Select] SELECT a.*, b.* FROM friendlist a INNER JOIN attend b ON (a.friendemail=b.email) WHERE a.email='$email' GROUP BY b.eventid ORDER BY count(*) DESC LIMIT 5 This query returns the right results in PHPmyadmin, but when it's executed in a php file through the chrome or firefox, it doesn't display anything. As in the entire webpage won't show up. In chrome, it says server error any ideas? I had this code working, then I became curious and tried something else and it failed. I then I went to use the original code that worked but forgot it. Whats wrong with this code? <?php $A=(echo '2); if ($_POST['number'] == '1') {include $A;} ?> Hiya peeps! I have built this code, can anyone see anything wrong with this because its not working at all all it does is refer back to its self; <?php session_start(); include 'system/template/template.php'; include 'system/mysql/mysql.php'; include 'system/properties/property.php'; $mysql = new mysql(); $mysql->connect(); $property = new property(); if($property->landlord_loggedin()) { header('Location: login.php'); } $_SESSION['N_P_ID'] = 1; if(isset($_SESSION['N_P_ID']) && !empty($_SESSION['N_P_ID'])) { if(isset($_POST['videotitle']) && !empty($_POST['videotitle']) && isset($_FILES['videofile']) && !empty($_FILES['videofile'])) { $upload = $bad . '<form id="Upload" action="upload_video.php" enctype="multipart/form-data" method="post"> <h3>Upload a video of your property</h3> <label>Video Title</label> <input type="text" name="videotitle"><br /> <input type="file" name="videofile"> <label>Submit</label> <input type="submit" name="submit" value="Upload"><br /> <a href="landlord_account.php">Skip</a> </form>'; $extensions = array('mpg', 'avi', 'mpeg'); define ("MAX_SIZE","10240"); function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } if(isset($_FILES['imageone'])) { if(!isset($_POST['videotitle'])) { $bad = '<p class="bad">Please enter a video title.</p>'; $form = $upload; } $filename = stripslashes($_FILES['videofile']['name']); $extension = strtolower(getExtension($filename)); if(!in_array($extension, $extensions)) { $bad = '<p class="bad">Video is incorrect format, please make sure your video format is either mpg/mpeg or avi.</p>'; $form = $upload; } else { $size = filesize($_FILES['videofile']['tmp_name']); if($size > MAX_SIZE*1024) { $bad = '<p class="bad">Video too large.</p>'; $form = $upload; } $time = time(); $image_name = $time . '.' . $extension; $newname = "uploads/properties/landlord_files/videos/" . $image_name; if(move_uploaded_file($_FILES['videofile']['tmp_name'], $newname)) { if($property->add_video($time, 'flv', $_POST['videotitle'])) { $srcFile = 'uploads/properties/landlord_files/videos/' . $image_name; $destFile = 'uploads/properties/landlord_files/videos/' . $time . '.flv'; $ffmpegPath = "/usr/bin/ffmpeg"; $flvtool2Path = "/usr/bin/flvtool2"; $ffmpegObj = new ffmpeg_movie($srcFile); $srcWidth = makeMultipleTwo($ffmpegObj->getFrameWidth()); $srcHeight = makeMultipleTwo($ffmpegObj->getFrameHeight()); $srcFPS = $ffmpegObj->getFrameRate(); $srcAB = intval($ffmpegObj->getAudioBitRate()/1000); $srcAR = $ffmpegObj->getAudioSampleRate(); $img = $image_name; $ff_frame = $ffmpegObj->getFrame(1); if($ff_frame) { $gd_image = $ff_frame->toGDImage(); if($gd_image) { imagepng($gd_image, $img); imagedestroy($gd_image); $property->add_image($img, 'png', 'frame_shot'); } } exec($ffmpegPath . " -i " . $srcFile . " -ar " . $srcAR . " -ab " . $srcAB . " -f flv -s " . $srcWidth . "x" . $srcHeight . " " . $destFile . " | " . $flvtool2Path . " -U stdin " . $destFile); @unlink($newname); function makeMultipleTwo ($value) { $sType = gettype($value/2); if($sType == "integer") { return $value; } else { return ($value-1); } } $ref = 1; } else { @unlink($newname); $bad = '<p class="bad">Video upload failed.</p>'; $form = $upload; } } else { $bad = '<p class="bad">Video upload failed.</p>'; $form = $upload; } } } if($ref == 1) { header('Location: landlord_account.php?page=3'); } } else { $form = '<form id="Upload" action="upload_video.php" enctype="multipart/form-data" method="post"> <h3>Upload a video of your property</h3> <label>Video Title</label> <input type="text" name="videotitle"><br /> <input type="file" name="videofile"> <label>Submit</label> <input type="submit" name="submit" value="Upload"><br /> <a href="landlord_account.php">Skip</a> </form>'; } $template = new template(); $array = array('TITLE' => 'Upload A Video', 'CONTENT' => $form); $template->newTemplate($array, 'add_property'); } else { header('Location: landlord_account.php'); } ?> Many thanks, James. |