PHP - Why Isnt This Working? (max Function)
im trying to return the highest value in my table from the season_id column
this is the code i have: Code: [Select] $test = mysql_query("SELECT * FROM `$show` WHERE [season_id]=(SELECT Max([season_id]) FROM `$show`)"); please advise? Similar Tutorialsit worked before, although now $value consists of a space and i think it may be messing things up. i pass a form field Code: [Select] <input type="text" name="attributes[]" id="attributes[]"> and then i do this... In the case above the 3 attributes[] passed are "Value 1", "Value 2", "Value 3" $attribute = ""; foreach($_POST['attributes'] as $key => $value) { $attribute .= $value . "/"; } $atr = explode("/",$attribute); #print_r($atr); foreach($atr as $key => $value) { #THIS IS WHERE THE ISSUE ARISES... $_POST[$value] wont work echo $_POST[$value] . "<BR>"; // DOES NOT WORK #echo $value . "<BR>"; // WORKS - shows "Value 1", etc.... #echo $_POST["VALUE 1"] . "--<BR>"; // DOESNT WORK EITHER } any ideas? im 90% certain if the $value variable was just "Value" and not "Value 1" it would work as it has before. Code: [Select] <?php session_start(); require_once("connect.php"); ?> <html> <body> Thanks for buying!<br> Receipt:<br> Amount:<?php echo ($_POST["amount"]);?> <br>Type:<?php echo $_POST["type"];?> <br>Cost:<?php if($_POST["type"]=="pikemen"){ $cost = 20 * $_POST["amount"]; $price = $_SESSION["resources"] - $cost; $name = $_SESSION["username"]; $gained = $_POST["amount"] + $_SESSION["pikemen"]; mysql_query("UPDATE SET pikemen = '$gained' WHERE username = '$name'"); } mysql_query("UPDATE SET resources = '$price' WHERE username = '$name'"); ?> </body> </html> The script is supposed to use some information taken from an input box on the previous page to buy items from the shop, but its not working (it doesnt give errors, just doesnt change the amount of soldiers or resources... Hi, I'm making a php game, and the image map isn't working. I don't know if it is a php or javascript issue, I don't think it is an html issue but I could be wrong so feel free to move this post. lol. But basically, The image map is supposed to link to an array of images. That is how the game works. There is the overworld image map, you click on a link, and go to the zone images, all in the same window. Any help GREATLY appreciated because having the image map feature work would be awesome finally. thanks. Derek. here is the code that uses the image map. I cut out a lot of the unnecessary code , but the image map functionality related code is in there. Code: [Select] <?php session_start(); ////////////////////////////////////////////////////////////////////////////////// /////////////////////////////GAME NAVIGATION AND MONSTER SEARCH CODE NOT FINISHED////////////////////////////////// $locations[0] = array(); $locations[1] = array( 'background_images' => array( "<img src='sundragon_environments/ocean/ocean1_FRAME.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME2.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME3.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME4.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME5.jpg'/>" ), 'monster_images' => array( "<img src='sundragon_monsters_source/water/goldfish/goldfish.png'/>", "<img src='sundragon_monsters_source/water/eel/eel_transp_FRAME.png '/>", "<img src='sundragon_monsters_source/water/shark/shark_transp_FRAME.png'/>", "<img src='sundragon_monsters_source/water/octalisk/octalisk_transp_FRAME.png'/>", "<img src='sundragon_monsters_source/water/teardrop_ocean_protector/teardrop_ocean_protector.png'/>" ) ); $locations[2] = array( 'backgroundImages' => array( //Array images go here. ) ); if(isset($_GET['newLocation'])) { $_SESSION['current_location']=$_GET['newLocation']; } if(!isset($_SESSION['current_location']) && !isset($_SESSION['current_background']) && !isset($_SESSION['currentMonster'])) { $_SESSION['current_location'] = 0; $_SESSION['current_monster'] = 0; $_SESSION['current_background'] = 0; } if($_SESSION['current_location'] != 0) { if(!isset($_SESSION['current_background']) && !isset($_SESSION['current_monster'])) { $_SESSION['current_monster'] = 0; $_SESSION['current_background'] = 0; } if(isset($_GET['further'])) { //below is- inside the locations array, teardrop ocean (1) the background image is 4(example)+1 is set, then //do this if(isset($locations[$_SESSION['current_location']]['background_images'][$_SESSION['current_background']+1])) { $_SESSION['current_background']+=1; } if(isset($locations[$_SESSION['current_location']]['monster_images'][$_SESSION['current_monster']+1])) { $_SESSION['current_monster']+=1; } } elseif(isset($_GET['back'])) { if(isset($locations[$_SESSION['current_location']]['background_images'][$_SESSION['current_background']-1])) { $_SESSION['current_background']-=1; } if(isset($locations[$_SESSION['current_location']]['monster_images'][$_SESSION['current_monster']-1])) { $_SESSION['current_monster']-=1; } } $currentBackground=$_SESSION['background'][$_SESSION['current_background']]; $currentMonster=$_SESSION['monster'][$_SESSION['current_monster']]; } else { //?newLocation=1 means set it to Teardrop ocean. $currentBackground = ' <img src="aradia.jpg" width="256" height="328" border="0" usemap="#Map" /> <map name="Map" id="Map"> <area shape="rect" coords="5,176,81,249" href="?newLocation=1"/> </map>'; $currentMonster = ''; } /////////////////////////////////////////////////////////////////////////////////////////////////// ?> <!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>Realm of the Sun Dragon</title> <link rel="stylesheet" type="text/css" href="css/gamestyles.css"> <style type="text/css"> body { margin-top:-32px; padding:0; color: gold; } table { color: black; } .style8 {color: #000000} </style> </head> <body oncontextmenu="return false;"> <div id="container"> <div id="monster_message"> <?php echo "this is the monster battle and NPC talk window";?> </div> <div id="currentWeapon"> <img src="sundragon_interface_template/items/swords/sword_shrunk.png" width="190" height="65" /> </div> <div id="iframe_player_top_lft" > <div id="left_player_stats"><table align="center" width="30" border="0"> <tr> <td><strong>HP</strong></td> <td><strong><font color="red"><?php echo $playerHp;?></font></strong></td> </tr> <tr> <td><strong>MANA</strong></td> <td><strong><font color="green"><?php echo $echoPlayerMana;?></font></td> </tr> <tr> <td><strong>EXP</strong></td> <td><strong><font color="blue">999</font></strong></td> </tr> <tr> <td><strong>PLAT</strong></td> <td><strong><font color="white">999</font></strong></td> </tr> </table></div> <p> </p> <p> </p> <p> </p> <p align="center"><strong><br /> <span class="style8">Octalisk (Level <?php echo $currentMonsterLevel;?>) </span></strong> <br/> <strong><span class="style8">HP</span><font color="red"> <?php echo $monsterHp;?></font></strong> </p> <div id="spelleffectsleft" > <div class="divcenter"> <div align="center"> <div class="inline"> <div align="center">spell</div> </div> <div class="inline"> <div align="center">spell</div> </div> <div class="inline"> <div align="center">spell</div> </div> </div> </div> <!--end divcenter--> </div><!--end spell effects--> <div id="bottomspellsleft" > <div class="divcenter"> <div class="inline"> <div align="center">spell</div> </div> <div class="inline"> <div align="center">spell</div> </div> <div class="inline"> <div align="center">spell</div> </div> </div> <!--end div center--> </div><!--end bottomspells--> </div><!-- end player div--> <div id="iframe_spell_foreground"><?php echo $echoSpell;?></div> <div id="iframe_monster_background"><?php echo $currentBackground;?></div> <div id="iframe_transparent_monster"><?php echo $currentMonster;?></div> <!--not here--> <div id="iframe_player_top_right" > <table width="160" height="64" border="0" align= "center"> <tr> <td width="160"><div align="center"> <p><strong><br /> Silverglade (Level: <?php echo $currentPLayerLevel;?>)<br /> </strong></p> </div></td> </tr> </table> <div class="spelleffects" > <div class="divcenter"> <div class="inline"> <div align="center">spell</div> </div> <div class="inline"> <div align="center">spell</div> </div> <div class="inline"> <div align="center">spell</div> </div> </div> </div> <div class="bottomspells" > <div class="divcenter"> <div class="inline"> <div align="center">spell</div> </div> <div class="inline"> <div align="center">spell</div> </div> <div class="inline"> <div align="center">spell</div> </div> </div> </div> </div> <div id="iframe_chat_right"> the data from the chat message box will be output to this div</div> <!--not here--> <div id="iframe_player_center_bottom" align="center" ><div style="display: inline;"> <form style="display: inline; margin: 0;" ...> <form style="display: inline; margin: 0;" action='gamestart_NEWEST.php' method='post'><input type='submit' name='attack' value='Attack'/><input type="submit" name="search" value="search" /><input type="submit" value="cast spell" name="spell" /><input type="submit" name="inventory" value="Inventory"/></form> <form style="display: inline; margin: 0;" method="get" action=""><input type="submit" value="go further" name="further" /> <input type="submit"value="Go back" name="back"/></form> </form> </div> <div id="chat"> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <strong>Message:</strong> <textarea name="message"></textarea> <input type="submit" name="submit" value="Chat"> <input type="hidden" name="ip" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>"> </form> </div></div></div> <!--not here--> <div id="log_off"> <a href="logout.php"><strong>LOG OFF</strong></a> </div> <!--not here--> </div> </body> </html> I am using an if statement. If the user has a credit value of 1 or more it echos a variable thats a form. When the user submits the form, it takes a credit away, so the credit value is -1. I need the form to dissapear, because the form has a button that will execute a query that I dont want to execute. So, usually unset() fixes this, but its not in my case. Heres the code Code: [Select] $a='<strong></strong>'; if ($hintcredit<1) $a.='<font style="color: #cc0000;">You have already requested a hint! Once you guess the correct number, you will be able to get another hint. </font>'; else $form= "<form action='blablabla' method='post'>blablablabla</form>"; $a.=$form; $a.='<strong></strong>'; echo $a; if ($_POST['request'] == "Retrieve Hint") { unset($form); $form= '<b>One of the digits in your number is '.substr($num, -1).'</b>'; $newquery= "UPDATE userinfo SET hint_credits = '-1' WHERE username = '".$_SESSION['login_name']."'"; echo $form; mysql_query($newquery,$link); } In this case, the form is still being shown. I need the form completely removed after the form has been submitted. This is simple and idk why its not working for me!? Hey Guys, In this portion of my code I have tried to implement pagination, as the results try to display a page with over 100 mp3's with flash players on teh page, and of course the page just dies. However my attempt at pagination isnt actually working. can anyone help this noob? <? // how many rows to show per page $rowsPerPage = 20; // by default we show first page $pageNum = 1; // if $_GET['page'] defined, use it as page number if(isset($_GET['page'])) { $pageNum = $_GET['page']; } // counting the offset $offset = ($pageNum - 1) * $rowsPerPage; $query = " SELECT val FROM ax_music " . " LIMIT $offset, $rowsPerPage"; $result = mysql_query($query) or die('Error, query failed'); // print the random numbers while($row = mysql_fetch_array($result)) { echo $row['val'] . '<br>'; } $row2 = mysql_query("SELECT * FROM ax_music ORDER BY 'sort' ASC"); while($row = mysql_fetch_array($row2)){ ?> <tr> <td><?=$row[title];?></td> <td> <embed src= "musicplayer2.swf" quality="high" width="300" height="52" allowScriptAccess="always" wmode="transparent" type="application/x-shockwave-flash" flashvars= "valid_sample_rate=true&external_url=./music/<?=$row[mp3];?>" pluginspage="http://www.macromedia.com/go/getflashplayer"> </embed> </td> <td> <? if($row[visible] == 0){ echo "<strong>Not Playlisted</strong><br /> <a href=\"index.php?page=musicplayer&showid=$row[id]\">Add To Playlist</a>"; }else{ echo "<strong>Playlisted</strong><br /> <a href=\"index.php?page=musicplayer&hideid=$row[id]\">Remove From Playlist</a>"; } ?> </td> <td><a href="index.php?page=musicplayer&deleteid=<?=$row[id];?>"><strong>Delete</strong></a></td> <td><a href="./music/<?=$row[mp3];?>"><strong>Download</strong></a></td> </tr> <? } ?> </table> Hi guys Probably a simple but trying to figure out why I cant get this while loop to work (at least I think its the loop) Query works as it returns 1 row, but not all of them. Any help would be great! $sql = "SELECT * FROM requests ORDER BY leave_after DESC"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_assoc($result)) { echo '<div id="resultholder">'; echo "<p>Request ID:" . $row['id'] . ", User ID: " . $row['user_id'] . ", Departing From: " . $row['departing'] . ", Going To: " . $row['destination'] . " , Leaving After: " . $row['leave_after'] . " , but Arriving Befo " . $row['arrive_before'] ."</p></div>"; echo '</div>'; } } } Thanks! Hiya peeps! I have built this. <?php class extract { private $link; private $rec; public function __construct() { } public function __init($link, $rec = 0) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$link); curl_setopt($ch, CURLOPT_TIMEOUT, 50); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $this->_data = curl_exec($ch); curl_close($ch); $this->_emails = array(); if($rec == 1) { if(preg_match_all('/((?:http|https):\/\/(?:www\.)*(?:[a-zA-Z0-9_\-]{1,15}\.+[a-zA-Z0-9_]{1,}){1,}(?:[a-zA-Z0-9_\/\.\-\?\&\:\%\,\!\;]*))/', $this->_data, $urls)) { foreach($urls[0] as $k => $v) { $this->__init($v, 1); } } } return $this->emails(); } public function emails() { if(preg_match_all('/(\w+\.)*\w+@(\w+\.)*\w+(\w+\-\w+)*\.\w+/', $this->_data, $emails, PREG_SET_ORDER)) { foreach($emails as $dk => $dv) { foreach($dv as $fk => $fv) { if(preg_match('/^[^@]+@[a-zA-Z0-9._-]+\.[a-zA-Z]+$/', $fv)) { $this->_emails[] = $fv; } } } } return $this->_emails; } public function multi_unique($array) { foreach ($array as $k => $na) { $new[$k] = serialize($na); $uniq = array_unique($new); } foreach($uniq as $k => $ser) { $new1[$k] = unserialize($ser); } return $new1; } } $go = new extract(); $done = $go->__init($_POST['site'], $_POST['deep']); print_r($done); ?> <center><form action="#" method="post"> Site:<br /><input type="text" name="site"><br /><br /> Go-Deep:<br /><select name="deep"><option value="0" selected>No</option><option value="1">Yes</option></select><br /><br /> <input type="submit" name="submit"> </form></center> It works, but only on one URL, I have setup a html page containing an email address and a link to another page containing an email address, so technically it should return two email addresses. But it doesn't, it only displayed the email address on the url that is inputted. Does anyone have any idea why? Many thanks, James. I dont understand why my header(Location) isnt working. Does any one see why?
<?php include 'core/init.php'; logged_in_redirect(); include 'includes/overall/header.php'; if (empty($_POST) === false) { $required_fields = array('first_name', 'last_name', 'username', 'password', 'password_again', 'email'); foreach($_POST as $key=>$value) { if (empty($value) && in_array($key, $required_fields) === true) { $errors[] = 'All field are required'; break 1; } } if (empty($errors) === true) { if (user_exists($_POST['username']) === true) { $errors[] = 'Sorry, the user \'' . $_POST['username'] . '\' is already taken'; } if (preg_match("/\\s/", $_POST['username']) == true) { $errors[] = 'Your username can not have spaces'; } if (strlen($_POST['password']) < 6) { $errors[] = 'Your password must be at least 6 characters long'; } if ($_POST['password'] !== $_POST['password_again']) { $errors[] = 'Your passwords do not match'; } if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false) { $errors[] = 'A valid email address is required'; } if (email_exists($_POST['email']) === true) { $errors[] = 'Sorry, the email \'' . $_POST['email'] . '\' is already is use. Please contact your site adimn is this is incorrect.'; } } } if (isset($_GET['success']) && empty($_GET['success'])) { echo '<div class="container"><div class="background-success text-center"><div class="alert alert-success center-background">You\'ve be registered successfully! Please check your email to activate your account</div><div class="center-background"><div class="center-text-background">if any issues occur please send us an email!! support@bettergamerzunited.com</div></div></div>'; } else { if(empty($_POST) === false && empty($errors) === true) { $register_data = array( 'first_name' => $_POST['first_name'], 'last_name' => $_POST['last_name'], 'username' => $_POST['username'], 'password' => $_POST['password'], 'email' => $_POST['email'], 'email_code' => md5($_POST['username'] + microtime()) ); register_user($register_data); header('Location: register.php?success'); exit(); } ?> <div class="container background"> <form action="" method="POST" class="form-horizontal" role="form"> <div class="form-group"> <label for="inputfirstname3" class="col-sm-2 control-label">First Name</label> <div class="col-sm-10"> <input type="text" name="first_name" class="form-control" id="inputfirstname3" value="" autocomplete="off" placeholder="First Name"> </div> </div> <div class="form-group"> <label for="inputlastname3" class="col-sm-2 control-label">Last Name</label> <div class="col-sm-10"> <input type="text" name="last_name" class="form-control" id="inputlastname3" value="" autocomplete="off" placeholder="Last Name"> </div> </div> <div class="form-group"> <label for="inputusername3" class="col-sm-2 control-label">Username</label> <div class="col-sm-10"> <input type="text" name="username" class="form-control" id="inputusername3" value="" autocomplete="off" placeholder="Username"> </div> </div> <div class="form-group"> <label for="inputemail3" class="col-sm-2 control-label">Email</label> <div class="col-sm-10"> <input type="email" name="email" class="form-control" id="inputemail3" value="" autocomplete="off" placeholder="Email Address"> </div> </div> <div class="form-group"> <label for="inputpassword3" class="col-sm-2 control-label">Password</label> <div class="col-sm-10"> <input type="password" name="password" class="form-control" id="inputpassword3" autocomplete="off" placeholder="Password"> </div> </div> <div class="form-group"> <label for="inputpassword_again3" class="col-sm-2 control-label">Validate Password</label> <div class="col-sm-10"> <input type="password" name="password_again" class="form-control" id="inputpassword_again3" autocomplete="off" placeholder="Validate Password"> </div> </div> <div class="form-group"> <div class="col-sm-10"> <p class="info">Please be aware that this does not mean that you are a member of Better Gamerz United. If you would like to be come a member please contuine with the registration and then fill out our application. Other wise you will have limited use of this site. Thank you Team BGU!! </p> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <button type="submit" class="btn btn-primary pull-right register">Register</button> </div> </div> </form> </div> <?php } include 'includes/overall/footer.php'; ?> the strange thing is...I have the exact same script on another part of my page and it works! the only thing that changed are the variable names and the path (which ive checked 27000 times) What this should do is check if you have a signature in the external file and if you do and you fill out the form correctly then it replaces your old signature with your new one. and if you dont have a signature already and filled out the form correctly then it should write your signature to the file...for some reason this isnt working after checking and rechecking...i need a second pair of eyes. Help please! if (isset($_POST['change_submit2'])) { if (($_SESSION['logged_in'] == '1') && ($signature_test != '1') && ($_POST['change_box2'] == 'CHANGE') && ($invalid_character_test != '1') && ($invalid_character_test1 != '1')) { $fh1 = fopen($users_signatures_path, 'r+'); fwrite($fh1, $sig_front); frwrite($fh1, $_POST['signature']); fwrite($fh1, $sig_back); fwrite($fh1, ' '); flose($fh1); echo 'You have succesfully created a signature!'; } elseif (($_SESSION['logged_in'] == '1') && ($signature_test == '1') && ($_POST['change_box2'] == 'CHANGE') && ($invalid_character_test != '1') && ($invalid_character_test1 != '1')) { $users_signatures_path1 = "../../users/users_signatures.txt"; $fh1 = fopen($users_signatures_path1, 'r+'); $read_fh1 = fread($_fh1, filesize($users_signatures_path1)); $the_new_sig = str_replace($mcurrent_sig, $mnew_sig, $read_fh1); fclose($fh1); $fh1 = fopen($users_signatures_path1, 'r+'); fwrite($fh1, $the_new_sig); fclose($fh1); echo $mnew_sig; echo 'Your signature has been succesfully changed!'; } elseif ($_SESSION['logged_in'] != '1') { echo 'You need to be logged in!'; } elseif ($_POST['change_box2'] != 'CHANGE') { echo 'You must fill in the "CHANGE" box!'; } elseif ($invalid_character_test == '1') { echo 'Contains illegal characters!'; } elseif ($invalid_character_test1 == '1') { echo 'Contains illegal characters!'; } } Hello! This may sound like a stupid question but i have been trying to get this working all day and its driving me crazy.
Ive been asked to take over development of this project, he sent me his code and its a little out of date so im trying to update it. Here is what i cant work out.
I have this little snippet of code:
if ($page == "showthread"){ showThread(); }There are several more like that, but you dont need a whole list. That code seems to be throwing up this error when i go to that specific page: Notice: Undefined index: error in ..... All well and good, i would usually do this: if (isset($page) == "showthread"){ showThread(); }Thats fine and dandy, the error goes away. But now, when i go to that page, it redirects me and gives me my error message for a non-existing page. Its really frustrating me. Can you help me fix this little error? Hi all, Ive had alot of problem with one script latly but I carnt see what it accually causing the problems. My script is giving me an error saying: Notice: Undefined variable: carin in /home/www/*****.com/test/test.php on line 23 And: Notice: Trying to get property of non-object in /home/www/*****.com/test/test.php on line 23 My Code: $carin1 = mysql_query ("SELECT carid FROM users WHERE username='$username'") or die (mysql_error()); $carin = mysql_fetch_object($carin1); // Use function to make sure there in a car.. function carcheck(){ if ($carin->carid == ''){ // LINE 23 echo ("You must be in a car before doing any races."); } else{ echo ("You are currently in: $carin->carid"); } exit(); } // End function Where its saying ive got an undefined variable carin I accually havent as it is defined. :S Anyone see what is wrong with that part of my script?. Thanks for your help. I have this code on my user registration form Code: [Select] <?php $flg = ""; $error = ""; if (isset($HTTP_GET_VARS["flg"])) $flg = $HTTP_GET_VARS["flg"]; switch ($flg) { case "yellow": $error = "<br><font class=\"txt12_red\">That Email Address already exists in our Database.<br>Please Select Another.<BR></font>"; break; case "red": $error = "<br><font class=\"txt12_red\">Please fill out all the required fields.<br>Please Try Again.<BR></font>"; break; case "blue": $error = "<br><font class=\"txt12_red\">Your Session has Expired.<br>Please Login Again.</font><BR>"; break; case "pink": $error = "<br><font class=\"txt12_red\"><BR>The Special Code you entered is not valid.<br>Please Try Again or Leave that field blank. </font><BR>"; break; case "white": $error = "<br><font class=\"txt12_red\"><BR>The fields are too long for our Database.<br>Please correct your data via this form.</font> <BR>"; break; default: $error = ""; } ?> and the registered form / page I have this validation and function Code: [Select] <?php // check to see if these variables have been set... if ((!isset($_SESSION["fname"])) || (!isset($_SESSION["lname"])) || (!isset($_SESSION["email"])) || (!isset($_SESSION["phone"])) || (!isset($_SESSION["city"])) || (!isset($_SESSION["status"])) || (!isset($_SESSION["province"]))) { resendToForm("?flg=red"); } // form variables must have something in them... if ($_SESSION['fname'] == "" || $_SESSION['lname'] == "" || $_SESSION['email'] == "" || $_SESSION['phone'] == "" || $_SESSION['city'] == "" || $_SESSION['status'] == "" || $_SESSION['province'] == "") { resendToForm("?flg=red"); } // make sure fields are within the proper range... if (strlen($_SESSION['fname']) > 35 || strlen($_SESSION['lname']) > 35 || strlen($_SESSION['email']) > 35 || strlen($_SESSION['phone']) > 35 || strlen($_SESSION['city']) > 35 || strlen($_SESSION['status']) > 35 || strlen($_SESSION['province']) > 35 || strlen($_SESSION['password']) > 30) { resendToForm("?flg=white"); } function resendToForm($flags) { reset ($_POST); // store variables in session... while (list ($key, $val) = each ($_POST)) { $_SESSION[$key] = $val; } // go back to the form... //echo $flags; header("Location: ./registration_form.php".$flags); exit; } ?> The validation is working as it goes back to user registration form, the problem is it's not displaying the error on Code: [Select] <?php echo $error; ?> What seems to be the problem? anyone? This is the function I wrote function getParagraph($myfile) { while (!feof($myfile)){ $data = fgets($myfile); $paragraph = explode("\n", $data); } return $paragraph; } When I print the array, it's empty. while ($paragraph = getParagraph($file)){ print_r($paragraph); } Prints to my webpage as: Array ( => ) The file is NOT empty, and it is formated by line breaks so I don't know what's not working. deleting works, but can't seem to get the add to work???? any ideas Code: [Select] <!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>Search User</title> <link href="stylesheet1.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery-1.4.3.js"></script> <script type="text/javascript" src="jquery.json-2.2.js"></script> <style type="text/css"> body { font-size:12px; font-family:Arial, Helvetica, sans-serif; } form { display:block; width:260px; } form .input{ width:120px; float:right; } form label { display:block; width:260px; clear:both; } form textarea { display:block; width:260px; } </style> <script type="text/javascript"> // alert("document loaded 1"); // $(document).ready(function(){ //$("#projectid").html("1"); // alert("document loaded 1"); function userlistgenerate(){ var data = { "operation" : "userlist", "users": [ { "userid" : "usr_id"}, ] // end of sales array } //alert("geldi 2"); //var dataString = JSON.(data); var dataString = $.toJSON(data); //alert("geldi 3"); // alert(dataString); $.post('UserSearchPBT.php', { data: dataString}, userlistResult, "text"); $("#selectedUserName").html(""); // $("selectedUserName").hide("fast"); } function userlistResult(res) { var obj = $.evalJSON(res); //alert(obj.ResultData); //$("#sales1Lastname").html("Lastname of sales[1]: " +obj.sales[0].lastname); $("#userlist").html(obj.ResultData); $("#selectedUserName").html(""); //$("selectedUserName").hide("fast"); } function UserSearchChoose(userid,username ,name,surname,email,phone,mobphone,isactive){ $("#userid").val(userid); $("#username").val(username); $("#name").val(name); $("#surname").val(surname); $("#email").val(email); $("#phone").val(phone); $("#mobphone").val(mobphone); $("#isuseractive").val(isactive); $("#useradd").hide("fast"); } function usersearch() { $("#useradd").show(); var name=$("#name").attr("value"); var surname=$("#surname").attr("value"); var data = { "operation" : "usersearch", "user": [ { "name" : name, "surname" : surname } ] // end of sales array } var dataString = $.toJSON(data); $.post('UserSearchPBT.php', { data: dataString}, usersearchResult, "text"); } function usersearchResult(res) { var obj = $.evalJSON(res); $("#userlist").html(obj.ResultData); } function userdelete() { var useridval = $("#userid").attr("value"); alert (useridval); var data = { "operation" : "teamdelete", "userid" : useridval } var dataString = $.toJSON(data); $.post('UserSearchPBT.php', { data: dataString}, userdeleteResult, "text"); } function userdeleteResult(res) { var obj = $.evalJSON(res); $("#successfailmessage").html(obj.SuccFailMessage); userlistgenerate(); } function useradd() { //alert ("team add a geliyor"); var userId = $("#userid").attr("value"); var username = $("#username").attr("value"); var usersurname = $("#surname").attr("value"); var useremail = $("#useremail").attr("value"); var userphone = $("#userphone").attr("value"); var usermob = $("#usermob").attr("value"); var useractive = $("#useractive").attr("value"); // alert ("--".projectId."-".userId."-".rolId."--"); var data = { "operation" : "useradd", "userId" : userId, "username" : username, "useremail" : useremail, "userphone" : userphone, "usermob" : usermob, "useractive" : useractive, "recuser" : 1 } var dataString = $.toJSON(data); $.post('UserSearchPBT.php', { data: dataString}, userdeleteResult, "text"); alert ("user add a geliyor ajax bitti"); } </script> </head> <body> <form id="iletisim"> <div id="formdiv"> <table><tr> <td><span id="successfailmessage"></span></td> <tr><td><span id="userlist"></span> </td></tr> <tr><td><span id="selectedUserName"></span></td></tr> <tr><td><label for="name">User Name<input class="input" name="username" id="username" type="text" value="" /></label></td></tr> <tr><td><label for="name">Name<input class="input" name="name" id="name" type="text" value="" /></label></td></tr> <tr><td><label for="surname">Surname<input class="input" name="surname" id="surname" type="text" value="" /></label><tr> <tr><td><label for="email">Email<input class="input" name="email" id="email" type="text" value="" /></label><tr> <tr><td><label for="phone">Phone<input class="input" name="phone" id="phone" type="text" value="" /></label><tr> <tr><td><label for="phone">Mobile Phone<input class="input" name="mobphone" id="mobphone" type="text" value="" /></label><tr> <tr><td><label for="phone">Is User Active(Y/N)<input class="input" name="isuseractive" id="isuseractive" type="text" value="" /></label></td></tr> <tr><td><a href='#' onclick="javascript:usersearch();">Search User</a> </td></tr><tr> <tr><td><a href='#' id="useradd" onclick="javascript:useradd();">Add</a> </td></tr><tr> <tr><td><a href='#' id="userdelete" onclick="javascript:userdelete();">Delete</a> </td></tr><tr> <tr><td><a href='#' id="userupdate" onclick="javascript:userupdate();">Update</a> </td></tr><tr> </table> <input type="hidden" id = "userid" value="" name="userid" /> </div> </form> </body> </html> Code: [Select] hello. On my function page I have this function. function GetClub($clubs) { $qFindClub = "SELECT * FROM clubs WHERE memberID = '$clubs'"; $rFindClub = mysql_query($qFindClub); $Club = mysql_fetch_array($rFindClub); return $Club; } now when I feed it the variable $myID. If I try to echo say the club name $Clubs = GetClub($myID); echo $Clubs['name']; Nothing happens as its not working properly. Can anybody see what I have done wrong? I am trying to make a ban function and i have the users id being passed through the URL and i can't seem to get it working.
<?php require 'connect.php'; include 'header.php'; error_reporting(E_ALL | E_NOTICE); session_start(); $ban = "SELECT id FROM $tbl_name WHERE id={$_GET['id']} AND active='$active'"; $banres = $con->query($ban); $row = $con->fetch_assoc($banres); $active = $row['active']; if($banres) { $active_update = "UPDATE $tbl_name SET active=0"; } ?> I am still new to programming PHP and this is the first time I am creating a function. Here is where I pull the function (scroll down to commented area) <table width="250" border="0" cellpadding="2" cellspacing="0"> <tr> <td width="145"><strong>Province:</strong></td> <td colspan="2" align="right"><? echo $prov ?></td> </tr> <tr> <td><strong>Postal:</strong></td> <td colspan="2" align="right"><? echo $postal ?></td> </tr> <tr> <td><strong>Lbs:</strong></td> <td colspan="2" align="right"><? echo $lbs ?></td> </tr> <tr> <td colspan="3"> </td> </tr> </table> <img src="/images/carriers/canpar.png" border="0"/> <table width="250" border="0" cellpadding="2" cellspacing="0"> <?php if ($debugmode == 'on') { ?> <tr> <td><strong>Cost:</strong></td> <td width="14" align="right"><strong>$</strong></td> <td width="71" align="right"><? echo number_format($dzone, 2, '.', '') ?></td> </tr> <?php if ($cp_markup != "") { ?><tr> <td><strong>Markup:</strong></td> <td align="right"><strong>$</strong></td> <td align="right"><? echo number_format($cp_mark, 2, '.', '') ?></td> </tr><?php } ?> <? $price = ( number_format($cp_mark, 2, '.', '') +number_format($dzone, 2, '.', '') ); } Else { ?> <tr> <td><strong>Price:</strong></td> <td align="right"><strong>$</strong></td> <td align="right"><? $price = ( number_format($cp_mark, 2, '.', '') +number_format($dzone, 2, '.', '') ); echo number_format($price, 2, '.', ''); ?></td> </tr> <? } ?> <?php if ($cp_fuelcharge != "") { ?><tr> <td><strong>Fuel Charge:</strong></td> <td align="right"><strong>$</strong></td> <td align="right"><? echo number_format($cp_fuelcharge, 2, '.', '') ?></td> </tr><?php } ?> <?php taxcalc(); //Here is the function pull echo $taxrow; // this is supposed to be defined in the function ?> <tr> <td class="priceresults"><strong>Total:</strong></td> <td align="right"class="priceresults"><strong>$</strong></td> <td align="right"class="priceresults"><?php $total = ( number_format($price, 2, '.', '') + number_format($tax, 2, '.', '') ); echo number_format($total, 2, '.', ''); ?></td> </tr> </table> Here is my taxcalc() function: function taxcalc() { if ($prov == "AB") { $gst = '5%'; $gstcalc = '0.05'; $tax = $price * $gstcalc; $taxrow = "<tr><td>GST ($gst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } if ($prov == "BC") { $hst = '12%'; $hstcalc = '0.12'; $tax = $price * $hstcalc; $taxrow = "<tr><td>HST ($hst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } if ($prov == "MB") { $gst = '5%'; $pst = '7%'; $gstcalc = '0.05'; $pstcalc = '0.07'; $gtax = $price * $gstcalc; $ptax = $price * $pstcalc; $tax = $gtax + $ptax; $taxrow = "<tr><td>GST ($gst):</td><td align='right'><strong>$</strong></td><td>" . number_format($gtax, 2, '.', '') . "</td></tr><tr><td>PST ($pst):</td><td align='right'><strong>$</strong></td><td>" . number_format($ptax, 2, '.', '') . "</td></tr>"; } if ($prov == "ON") { $hst = '13%'; $hstcalc = '0.13'; $tax = $price * $hstcalc; $taxrow = "<tr><td>HST ($hst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } if ($prov == "NB") { $hst = '13%'; $hstcalc = '0.13'; $tax = $price * $hstcalc; $taxrow = "<tr><td>HST ($hst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } if ($prov == "NL") { $hst = '13%'; $hstcalc = '0.13'; $tax = $price * $hstcalc; $taxrow = "<tr><td>HST ($hst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } if ($prov == "NS") { $hst = '15%'; $hstcalc = '0.15'; $tax = $price * $hstcalc; $taxrow = "<tr><td>HST ($hst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } if ($prov == "NT") { $gst = '5%'; $gstcalc = '0.05'; $tax = $price * $gstcalc; $taxrow = "<tr><td>GST ($gst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } if ($prov == "NU") { $gst = '5%'; $gstcalc = '0.05'; $tax = $price * $gstcalc; $taxrow = "<tr><td>GST ($gst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } if ($prov == "PE") { $gst = '5%'; $pst = '10%'; $gstcalc = '0.05'; $pstcalc = '0.10'; $gtax = $price * $gstcalc; $ptax = $price * $pstcalc; $tax = $gtax + $ptax; $taxrow = "<tr><td>GST ($gst):</td><td align='right'><strong>$</strong></td><td>" . number_format($gtax, 2, '.', '') . "</td></tr><tr><td>PST ($pst):</td><td align='right'><strong>$</strong></td><td>" . number_format($ptax, 2, '.', '') . "</td></tr>"; } if ($prov == "QC") { $gst = '5%'; $pst = '7.5%'; $gstcalc = '0.05'; $pstcalc = '0.075'; $gtax = $price * $gstcalc; $ptax = ($price + $gtax) * $pstcalc; $tax = $gtax + $ptax; $taxrow = "<tr><td>GST ($gst):</td><td align='right'><strong>$</strong></td><td>" . number_format($gtax, 2, '.', '') . "</td></tr><tr><td>PST ($pst):</td><td align='right'><strong>$</strong></td><td>" . number_format($ptax, 2, '.', '') . "</td></tr>"; } if ($prov == "SK") { $gst = '5%'; $pst = '5%'; $gstcalc = '0.05'; $pstcalc = '0.05'; $gtax = $price * $gstcalc; $ptax = $price * $pstcalc; $tax = $gtax + $ptax; $taxrow = "<tr><td>GST ($gst):</td><td align='right'><strong>$</strong></td><td>" . number_format($gtax, 2, '.', '') . "</td></tr><tr><td>PST ($pst):</td><td align='right'><strong>$</strong></td><td>" . number_format($ptax, 2, '.', '') . "</td></tr>"; } if ($prov == "YT") { $gst = '5%'; $gstcalc = '0.05'; $tax = $price * $gstcalc; $taxrow = "<tr><td>GST ($gst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } } I am not getting any errors, just nothing is showing up. My results show up as: Code: [Select] Province: ON Postal: K2C Lbs: 25 Cost: $ 22.57 Markup: $ 0.00 Fuel Charge: $ 5.00 Total: $ 22.57 After Fuel Charge should be my taxes but they do not show up Hi all , in my scripts I have a drop list and its <option> values are retrieved from sql database , and once I choose any value from the drop list the value will shown in a textbox . It's functioning well in firefox and opera except IE , is there any way to solve this problem? Code: [Select] <html> <head> <title>Untitled</title> </head> <body> <form name="theform" onsubmit="CheckForm()"> <?php $query="SELECT DISTINCT Custgroup FROM UserAddedRecord"; $result = mysql_query ($query); ?> <select name="myOptions" onchange="document.theform.showValue.value=this.value" > <? while($nt=mysql_fetch_array($result)){//Array or records stored in $nt echo "<option >$nt[Custgroup]</option>"; } ?> <input type="text" name="showValue"><br> </form> </body> </html> Thanks for every reply . I thought this was pretty straight forward, but it is not working. Titlecase is supposed to capitalize the first letter of every with except for certain words in $smallarr. Instead, it capitalizes every word. What's wrong here? //==================================================== function crTitlecase($s) /* Capitalize every word in a sentence except certain small words. */ { //Keep $smallarr in alpha order! //Do not capitalize these words. $smallarr=array('a','above','and','an','at','by','for','if'); $smallarr=array($smallarr,'into','is','it','of','off'); $smallarr=array($smallarr,'on','or','over','the','to'); $smallarr=array($smallarr,'with','without'); //$smallarr=($smallarr,); $t=strtolower($s); //First change all ltrs to lowercase. $words = explode(' ', $t); foreach ($words as $mykey => $word) { //if ((!$mykey) or (!in_array($word, $smallarr)) ) if ( (!in_array($word, $smallarr)) ) { $s='mykey='.$mykey.', word='.$words[$mykey]; crDebug($s); $words[$mykey] = ucwords($word); } } $newtitle = implode(' ', $words); return $newtitle; } For some reason the !isset() function doesnt seem to work i cant find out why hope you guys will be able to help Here is the html code for the form where the user enters the data Code: [Select] <div id="contact_form"> <h2>On Site SEO Signup Form</h2> <form method="post" name="contact" action="http://www.techbreeze.in/freeseo.php"> <label for="uname">Name:</label> <input name="uname" type="text" class="required input_field" id="uname" /> <div class="cleaner h10"></div> <label for="email">Email:</label> <input type="text" class="validate-email required input_field" name="email" id="email" /> <div class="cleaner h10"></div> <label for="website">Website:</label> <input type="text" class="required input_field" id="website" name="website"/> <div class="cleaner h10"></div> <label for="ftp">Your FTP Login URL:</label> <input type="text" class="required input_field" id="url" name="url" /> <div class="cleaner h10"></div> <label for="username">Your FTP Username:</label> <input type="text" class="required input_field" id="user" name="user" /> <div class="cleaner h10"></div> <label for="password">Your FTP Password:</label> <input type="password" class="required input_field" id="pass" name="pass"/> <div class="cleaner h10"></div> <input type="submit" value="Send" id="submit" name="submit" class="submit_btn float_l" /> <input type="reset" value="Reset" id="reset" name="reset" class="submit_btn float_r" /> </form> </div> And here is the code for the .php file where the !isset() function is used Code: [Select] <?php // validation expected data exists if( !isset($_POST['uname'])) { die ('We are sorry, but all the fields are necessary you cant leave the "Name" field empty!'); } if( !isset($_POST['pass'])) { die ('We are sorry, but all the fields are necessary you cant leave the "Password" field empty!'); } if( !isset($_POST['email'])) { die ('We are sorry, but all the fields are necessary you cant leave the "Email" field empty!'); } if( !isset($_POST['website'])) { die ('We are sorry, but all the fields are necessary you cant leave the "Website" field empty!'); } if( !isset($_POST['url'])) { die ('We are sorry, but all the fields are necessary you cant leave the "FTP URL" field empty!'); } if( !isset($_POST['user'])) { die ('We are sorry, but all the fields are necessary you cant leave the "Username" field empty!'); Thanks in advance |