PHP - Variable Not Echoing
I have stored some texts in the database associated with a variable name in my database ... I intend to use this in my site as global text using the variable name ... This is the code I've created in a php file, which I'm 'including' in my webpage . <div style="display:none"> <?php mysqli_select_db($xxx, $database_xxx); $query_Recordset1 = "SELECT * FROM text_declares"; $Recordset1 = mysqli_query($xxx, $query_Recordset1) or die(mysqli_error()); $row_Recordset1 = mysqli_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysqli_num_rows($Recordset1); ?> <?php do { echo '$' . $row_Recordset1['bd_variable'] . ' = "' . $row_Recordset1['bd_desc'] . '"<br>'; } while ($row_Recordset1 = mysqli_fetch_assoc($Recordset1)); echo 'Company Name =' . $company_full_name ; ?> </div> When i execute the file, this is the ouput Quote
$company_full_name = "Some Company Pvt. Ltd." not able to figure out why the $company_full_name is not showing in the echo. Many Thanks for the support . Similar TutorialsHi, I am trying to insert a variable in the body of an email lik so: Code: [Select] $message = "Dear Administrator,\n\nthe following distributor\n\n'.$row_admin_login_RS['distributor_company_name'].'\n\nHas modified his Distributor information record.\n\"; I know it must be a syntax error...but I can't figure it out. Thanks Hi, I know it is probely not a regex question but I don't know the right category. I have 2 variables like $variable1 and $ variable2 which are placed in a loop now I want the $variable to be echo't in a link like <a href="http://exampe.com/$variable1"/> On this dynamicly generated page I want to output the $varible1 of this link and $variable2 while($row = mysql_fetch_assoc($result)) { echo " <tr>"; echo " <td>" . $row["variable1"] . "</td>"; echo " <td>" . $row["variable2"] . "</td>"; echo " </tr>"; Hi, I'm working on a page that GETs a value that is passed in the URL. This variable echos correctly up until I try echoing it inside an if statment where it needs to be. The variable is called $siteid. Inside my if statement I have a query that runs WHERE id='$siteid' Inside this if statement it won't echo out. It is the weirdest thing. I tried to hardcode the siteid as 95, to test it, and the query updated my database as it should. However, leaving it as the variable it will not work. Any help solving this mystery that I've been banging my head over for hours would be greatly appreciated! My variable echos correctly up until the line that says: // $siteid will Echo up until here. After this point it stops working. The query I am having issues with is after the line that says: // Problem lies in this query. My SQL Table: id int(11) No userid int(11) No url varchar(2083) No credits int(11) No 0 dailyviews int(11) No 0 todayviews int(11) No 0 totalviews int(11) No active tinytext No title varchar(50) No confirmed tinytext No And my code: <?php session_start(); if (isset($_SESSION['username'])){ $loginstatus = "logout"; $username = $_SESSION['username']; include_once('inc/connect.php'); $siteid = $_GET['siteid']; $message = "messagebox"; $success = " "; $error = " "; $useridquery = "SELECT id FROM users WHERE username='$username'"; $useridresult = mysql_query($useridquery); $useridrow = mysql_fetch_assoc($useridresult); $userid = $useridrow['id']; $result1 = mysql_query("SELECT * FROM websites WHERE `id`='$siteid' && userid='$userid'"); $siterow1 = mysql_fetch_assoc($result1); $titledb = $siterow1['title']; $urldb = $siterow1['url']; $maxviewsdb = $siterow1['dailyviews']; $statusdb = $siterow1['active']; $titlenew = $_POST['title']; $urlnew = $_POST['url']; $maxviewsnew = $_POST['maxviews']; $statusnew = $_POST['status']; if($statusnew=="Active"){ $statusnew = "yes"; } else{ $statusnew = "no"; } $editnewsite = $_POST['editnewsite']; if($success!=""){ $message = ""; } else{ $message = "messagesuccess"; } // $siteid will Echo up until here. After this point it stops working. if($editnewsite){ if($titlenew){ if($urlnew){ if($maxviewsnew){ function valid_url($urlnew) { return ( ! preg_match('/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i', $urlnew)) ? FALSE : TRUE; } if(valid_url($urlnew)){ //Check if URL is a Duplicate for current user $results = mysql_query("SELECT * FROM `websites` WHERE `userid`='$userid' AND `url`='$url'"); $rows = mysql_num_rows($results); if ($rows<=0) { $siteidnew = $siteid; // Problem lies in this query. $update = "UPDATE `websites` SET `title`='$titlenew', `url`='$urlnew', `dailyviews`='$maxviewsnew', `active`='$statusnew' WHERE `id`='$siteid' && `userid`='$userid'"; mysql_query($update); $titledb = $titlenew; $urldb = $urlnew; $maxviewsdb = $maxviewsnew; $statusdb = $statusnew; echo $titledb; echo $urldb.$maxviewsdb.$statusdb."<br>".$siteid; // PROBLEM HERE exit(); } else{ $error = "You have already submitted that site"; $message = "messageerror"; } } // here else { $error = "Invalid URL"; $message = "messageerror"; } } else{ $error = "Type in the Maximum Views you<br />want your site to get daily!"; $message = "messageerror"; } } else{ $error = "Type in the Url of your website!"; $message = "messageerror"; } } else{ $error = "Type in a Title for your site!"; $message = "messageerror"; } } } else{ $loginstatus = "login"; header("Location: index.php"); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="description" content="Free Piano Sheet Music - Sheet Music Haven" /> <meta name="keywords" content="Piano,Sheet,Music,Haven,Score,Piece,Top,Trade" /> <meta name="author" content="Sheet Music Haven" /> <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" /> <title>Edit Sites - Sheet Music Haven</title> <link rel="stylesheet" type="text/css" href="styles/style.css" /> <link rel="stylesheet" type="text/css" href="styles/editsites.css" /> <script type="text/javascript"> function make_blank() { if(document.login.username.value =="Username"){ document.login.username.value =""; document.login.username.style.color ="#000000"; } } function make_blank1() { if(document.login.password.value =="Password"){ document.login.password.value =""; document.login.password.type ="password"; document.login.password.style.color ="#000000"; } } function undoBlank() { if(document.login.username.value == ""){ document.login.username.value ="Username"; document.login.username.style.color="#ccc"; } } function undoBlankpass() { if(document.login.password.value == ""){ document.login.password.value ="Username"; document.login.password.style.color="#cccccc"; } } function inputLimiter(e,allow) { var AllowableCharacters = ''; if (allow == 'NumbersOnly'){AllowableCharacters='1234567890';} var k; k=document.all?parseInt(e.keyCode): parseInt(e.which); if (k!=13 && k!=8 && k!=0){ if ((e.ctrlKey==false) && (e.altKey==false)) { return (AllowableCharacters.indexOf(String.fromCharCode(k))!=-1); } else { return true; } } else { return true; } } </script> </head> <body bgcolor="#343331"> <!-- Header --> <div id="header"> <div id="headerleft"></div> <div id="headermiddle"><a href="index.php"><img src="img/logo.png"></a></div> <div id="headerright"> <?php echo "<form name='login' action='inc/$loginstatus.php' method='POST'>";?> <div class="loginboxdiv" id="username"> <input type="text" class="loginbox" name="username" value="Username" onFocus="make_blank();" onBlur="undoBlank();"> </div> <div class="loginboxdiv" id="password"> <input class="loginbox" type="text" name="password" type="text" value="Password" onFocus="make_blank1();" onBlur="undoBlankpass();"> </div> <div id="login"> <?php echo "<input type='image' src='img/$loginstatus.png' alt='".ucfirst($loginstatus)."'>";?> </div> </form> <div id="register"> <a href="register.php"><img src="img/register.png"></a> </div> <div id="forgotpassword"> <a href="resetpassword.php" class="forgot">Forgot Password?</a> </div> </div> </div> <!-- Content Top --> <div id="contenttop"> <div id="links"> <table cols="7"> <tr> <td align="center" valign="middle" width="100px" height="48px"><a href="index.php"><img src="img/home.png"></a></td> <td align="center" valign="middle" width="100px" height="48px"><a href="member.php"><img src="img/member.png"></a></td> <td align="center" valign="middle" width="100px" height="48px"><a href="addsheet.php"><img src="img/addsheet.png"></a></td> <td align="center" valign="middle" width="100px" height="48px"><a href="advertise.php"><img src="img/advertise1.png"></a></td> <td align="center" valign="middle" width="100px" height="48px"><a href="faq.php"><img src="img/faq.png"></a></td> <td align="center" valign="middle" width="100px" height="48px"><a href="terms.php"><img src="img/terms.png"></a></td> <td align="center" valign="middle" width="100px" height="48px"><a href="contact.php"><img src="img/contact.png"></a></td> </tr> </table> <!-- 92x30 --> </div> </div> <!-- Content Middle --> <div id="contentmiddle"> <div id="content"> <div id="headeditsites"></div> <br /> <div id="editsite"> <form action="editsites.php" method="post" name="newsite"> Title: <input type="text" name="title" value="<?php echo $titledb; ?>"><br /> Url: <input type="text" name="url" value="<?php echo $urldb; ?>"><br /> Max Views: <input type="text" maxlength="11" id="NumbersOnly" onkeypress="return inputLimiter(event,'NumbersOnly')" name="maxviews" value="<?php echo $maxviewsdb; ?>"><br /> <select name="status"><option value='Active' name='active'>Active</option><option value='Passive' name='passive'>Passive</option></select><br /><br /> <center><input type="submit" name="editnewsite" value="Edit Site"></center> </form> </div> </div> </div> <!-- Content Bottom --> <div id="contentbottom"> </div> </body> </html>
When I echo out my variable in the php file it works fine but when I put the variable in a table cell it doesn't echo out. $lastfm = file_get_contents('http://www.last.fm/group/Rishloo/members'); $users = explode('" id="r4_', $lastfm); $users = explode('">', $users[1]); var_dump($users[0]); that is only echoing one ID http://www.last.fm/group/Rishloo/members 1 id for each member it should be echoing.. any idea why it isnt? $lastfm = file_get_contents('http://www.last.fm/group/Rishloo/members'); $grab_id=explode('" id="r4_', $lastfm); for($b=1; $b<count($grab_id); $b++){ $getid=explode('">', $grab_id[$b]); echo count($getid[0]); } that echos all 1's.. any help is appreciated.. thanks thanks Hello, I have a PHP page (below) that is suppose to update a field in my database. For some reason it does not update. I am trying to echo that sql with this script. Any help would be greatly appreciated. Thanks JR Code: [Select] $p = (100-$_POST[$c])/100; $sql = "delete from products_groups where customers_group_id = ".$sppc['customers_group_id']; echo $sql; tep_db_query($sql); $sql = "insert into products_groups select '". $sppc['customers_group_id'] ."' as customers_group_id, ( " . $p . " * p.products_price) as customers_group_price, p.products_id from products p"; echo $sql; tep_db_query($sql); Below is the complete code, Code: [Select] <?php require('includes/application_top.php'); ?> <!DOCTYPE html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo TITLE; ?></title> <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> <script language="javascript" src="includes/general.js"></script> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();"> <div id="popupcalendar" class="text"></div> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'template_top.php'); ?> <!-- header_eof //--> <?php if (isset($_POST['Update'])) { $sppc_query_raw = "select * from " . TABLE_CUSTOMERS_GROUPS . " order by customers_group_id"; $sppc_query = tep_db_query($sppc_query_raw); while( $sppc = tep_db_fetch_array( $sppc_query ) ) { if ($sppc["customers_group_name"] != "Retail"){ //$sppc['customers_group_id'] $c = "CG_".$sppc['customers_group_id']; $tmp = $_POST[$c]; if ($tmp != 0) { $p = (100-$_POST[$c])/100; tep_db_query("delete from products_groups where customers_group_id = ".$sppc['customers_group_id']); tep_db_query ("insert into products_groups select '". $sppc['customers_group_id'] ."' as customers_group_id, ( " . $p . " * p.products_price) as customers_group_price, p.products_id from products p"); } //if not 0 } //if not Retail } } ?> <!-- body //--> <table border="0" width="100%" cellspacing="2" cellpadding="2"> <tr> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft"> </table></td> <!-- body_text //--> <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo "Special Pricing Discount Setup"; ?></td> <td class="specialPrice" align="right"> </td> </tr> </table></td> </tr> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td valign="top"><table border="0" width="100%" cellspacing="2" cellpadding="2"> <tr class="dataTableHeadingRow"> <td class="dataTableHeadingContent" align="left"> <?php if (isset($_POST['Update'])) { echo "<center>Updated!</center>"; } ?> </td> </tr> <?php $sppc_query_raw = "select * from " . TABLE_CUSTOMERS_GROUPS . " order by customers_group_id"; $sppc_query = tep_db_query($sppc_query_raw); while( $sppc = tep_db_fetch_array( $sppc_query ) ) { ?> <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)"> <td class="dataTableContent" align="left"> <?php if ($sppc["customers_group_name"] != "Retail"){ echo $sppc["customers_group_name"]; } if (isset($_POST['Update'])) { if ($sppc["customers_group_name"] != "Retail"){ $c = "CG_".$sppc['customers_group_id']; $tmp = $_POST[$c]; echo " Current Discount is $tmp%" ; } } ?> </td> </tr> <?php } ?> </table></td> </tr> <tr> <td valign="top"> <form action="" method="post"> <table border="0" width="40%" cellspacing="0" cellpadding="2"> <tr> <td class="smallText" align="left"> </td> <td> </td> </tr> <?php $sppc_query_raw = "select * from " . TABLE_CUSTOMERS_GROUPS . " order by customers_group_id"; $sppc_query = tep_db_query($sppc_query_raw); while( $sppc = tep_db_fetch_array( $sppc_query ) ) { if ($sppc["customers_group_name"] != "Retail"){ ?> <tr> <td class="smallText" align="left">Set New Percentage (%) Discount for <?=$sppc["customers_group_name"]?> :</td> <td><input name="CG_<?=$sppc['customers_group_id']?>" type="text" size="5" value="0"></td> </tr> <?php } } ?> <tr> <td colspan="2" align="center"><input type="submit" name="Update" value="Update"></td> </tr> </table> </form> </td> </tr> </table></td> <!-- body_text_eof //--> </tr> </table> <!-- body_eof //--> <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> This problem is existing on a few pages so I'll be in the clear if I can figure out to solve it on one page. Problem is on form submission its still echoing back that sortorder variable which makes it hard for it to compare on the success function to display the right message because the message should be good, bad1, bad2, ... . So is there anyway around that or do I need to do something on the client side of the form page. <?php // Include the database page require ('../inc/dbconfig.php'); if ( isset( $_POST['menuid'] ) ) { $menuid = (int)$_POST['menuid']; $query = "SELECT COUNT(sortorder) AS numOrder FROM `menuitems` WHERE `menu_id` = '".$menuid."'"; $result = mysqli_query ($dbc, $query); $row = mysqli_fetch_array( $result, MYSQL_ASSOC ); $sortorder = $row[ 'numOrder' ] + 1; echo $sortorder; } if (isset($_POST['submitmenuitem'])) { $menuid = mysqli_real_escape_string($dbc, $_POST['menuid']); $itemname = mysqli_real_escape_string($dbc, $_POST['itemname']); $itemurl = mysqli_real_escape_string($dbc, $_POST['itemurl']); $sortorder = mysqli_real_escape_string($dbc, $_POST['sortorder']); $contentpage = mysqli_real_escape_string($dbc, $_POST['contentpage']); $newscategory = mysqli_real_escape_string($dbc, $_POST['newscategory']); $application = mysqli_real_escape_string($dbc, $_POST['application']); $query = "SELECT * FROM `menuitems` WHERE (`itemname` = '".$itemname."') OR (`itemurl` = '".$itemurl."') OR (`contentpage_id` = '".$contentpage."') OR (`application_id` = '".$application."') OR (`newscategory_id` = '".$newscategory."') AND `menu_id` = '".$menuid."'"; $result = mysqli_query ( $dbc, $query ); // Run The Query $rows = mysqli_num_rows($result); if ($rows == 0) { $query = "INSERT INTO `menuitems` (menu_id, itemname, itemurl, sortorder, contentpage_id, newscategory_id, application_id, creator_id, datecreated, enabled) VALUES ('".$menuid."','".$itemname."','".$itemurl."','".$sortorder."','".$contentpage."', '".$newscategory."', '".$application."', 1, NOW(), 0)"; mysqli_query($dbc, $query); echo "good"; } else { $row = mysqli_fetch_array($result); if (($row['itemname'] == $itemname) && ($row['newscategory_id'] == $newscategory)) echo 'bad9'; elseif (($row['itemname'] == $itemname) && ($row['application_id'] == $application)) echo 'bad8'; elseif (($row['itemname'] == $itemname) && ($row['contentpage_id'] == $contentpage)) echo 'bad7'; elseif (($row['itemname'] == $itemname) && ($row['itemurl'] == $itemurl)) echo 'bad6'; elseif ($row['newscategory_id'] == $newscategory) echo 'bad5'; elseif ($row['application_id'] == $application) echo 'bad4'; elseif ($row['contentpage_id'] == $contentpage) echo 'bad3'; elseif ($row['itemurl'] == $itemurl) echo 'bad2'; elseif ($row['itemname'] == $itemname) echo 'bad1'; } } if (isset($_POST['deletemenuitem'])){ $menuitemID = (int)$_POST['menuitemID']; $query = "UPDATE `menuitems` SET `enabled` = '1' WHERE `id` = '".$menuitemID."' LIMIT 1"; mysqli_query($dbc,$query); } ?> Hello guys, I want to get the values of 3rd level of my referral but it did not echo any value but if i put the ref id directly on the code, it will echo the values. why is it so? or am i doing it the wrong way? in my database i have a table test_referral id acct_name ref_id refer_id 1 john J1234 0 2 bull B3456 J1234 3 doe D5567 J1234 4 frank F7788 J1234 5 jimmy J9990 J1234 6 tommy T6784 F7788 7 tom T9988 F7788 8 girly G8866 D5567 9 fred F0099 J9990 10 ronaldo R7722 B3456 thanks $stmt= $pdo->query("SELECT * FROM test_referral WHERE acct_name='Chidi Okafor'"); $parent = $stmt->fetch(PDO::FETCH_LAZY); echo "<ul><li>"; echo $parent['acct_name']; $ref_id = $parent['ref_id']; echo "</li><ul>"; $stmt= $pdo->query("SELECT * FROM test_referral WHERE refer_id='$ref_id'"); $child_count = $stmt->rowCount(); while($child = $stmt->fetch(PDO::FETCH_LAZY)){ echo "<li>"; echo $child['acct_name']; $ref_ids = $child['ref_id']; echo "</li>"; } //$reff = "F7788"; //$stmt= $pdo->query("SELECT * FROM test_referral WHERE refer_id='$F7788'"); $stmt= $pdo->query("SELECT * FROM test_referral WHERE refer_id='$ref_ids'"); $child_count2 = $stmt->rowCount(); while($children = $stmt->fetch(PDO::FETCH_LAZY)){ echo "<ul><li>"; echo $children['acct_name']; echo "</li></ul>"; } Edited by Mr-Chidi, 25 December 2014 - 05:34 AM. Hi, I'm trying to echo some error message like this: Code: [Select] <?php echo (isset($_GET['failed']))?'.CNT_TXT_MYERRORMESSAGE.''; ?> i know it must be a syntax error....but I'm a newb.... Thanks Hey i'm just woundering how i would echo numbers from a database like 1000000 lets say 1 million how would i go about on echoing it like this 1,000,000 ZhsHero Hi, I have this variable that checks which page we're on: Code: [Select] <?php $checkit = $_SERVER['PHP_SELF']; ?> and I need to echo some text depending which page we're on. I am using this code to do so: Code: [Select] <?php if ($checkit=="index.php") { echo "this is the home page"; } if ($checkit=="index2.php") { echo "this is the other page"; }?>...but nothing is printed. what am i doing wrong? Thanks how do i echo "checked=checked" for a checkbox? here is what i have: Code: [Select] <input type='checkbox' name='ip_automatic_login' id='ip_automatic_login' value='1' if($IPCheck == true) {/"checked=checked/" } /> this code will be echoed! I am having issue creating a checkbox that uses a onClick() js method. I believe this might be due to the fact that I am echoing the html but if any one could help id appreciate it. echo "<tr><td>WrkComp</td><td><input type='checkbox'" ?> <script>onClick="show()" </script> <? "name='WrkComp[]' value='DEP' '.$checked.' '.$Disabled.'/></td>"; Okay, I am having trouble. My script is not echoing the errors on the page/nor logging me in. If I check the browser source code it shows the error. here are my pages please help this is stupid ha index.php Code: [Select] <?php session_start(); include("includes/config.php"); if($_POST['submit']) { include("includes/action/".strtolower($_POST['submit']).".php"); } if (isset($_SESSION['SecureUid'])) { echo "Welcome Member!"; } else { echo $_SESSION['SecureUid']; $Larray = array ( "Username" => array("text","LoginUsername"), "Password" => array("password","LoginPassword"), "Hidden" => array("hidden","SecureHidden"), "Login" => array("submit","Login"), ); if ($LoginErrors) { foreach ($LoginErrors as $val) { echo "{$val}<br />"; } $Site->ClearErrors(); } $CreateForm = $Site->CreateForm("Login","{$_SERVER['PHP_SELF']}","post",$Larray); echo $CreateForm; } ?> includes/config.php Code: [Select] <?php ini_set( "display_errors", true ); date_default_timezone_set( "America/Phoenix" ); define( "CLASS_PATH", "includes/classes" ); //define( "TEMPLATE_PATH", "templates" ); define( "HOMEPAGE_NUM_ARTICLES", 5 ); function handleException( $exception ) { echo "Sorry, a problem occurred. Please try later."; error_log( $exception->getMessage() ); } set_exception_handler( 'handleException' ); include(CLASS_PATH."/class.database.php"); include(CLASS_PATH."/class.actions.php"); $Site = new Actions; $Site->connect(); $Site->setDatabase("ccloyd_rigid"); ?> includes/actions/login.php Code: [Select] <?php //log user in if ($_POST['SecureHidden']) { $Login = $Site->LoginUser(array("Username" => $_POST['LoginUsername'], "Password" => $_POST['LoginPassword'])); if ($Login) { $_SESSION['SecureUid'] = $Site->Uid; $_SESSION['SecureLevel'] = $Site->getLevel($Site->Uid); } else { $LoginErrors = $Site->ReturnErrors("Login"); } } ?> includes/classes/class.actions.php Code: [Select] <?php class Actions extends Database { public $Uid; //Login Vars private $Username; private $Password; //Errors Array private $Errors = array(); public function LoginUser($info, $admin = NULL) { //ugh //startover foreach ($info as $key => $val) { $this->{$key} = mysql_real_escape_string($val); } $this->Password = $this->EncryptPass($this->Password); if ($this->Username == '' || $this->Password == '') { $this->Errors["Login"] = array('Invalid Credentials!'); return false; } $Check = $this->select("users","`id`","username = '{$this->Username}' AND password = '{$this->Password}'"); if ($Check) { $Result = $this->getResult(); $id = $Result[id]; $this->Uid = $id; return true; } else { $this->Errors["Login"] = array('Invalid Credentials!'); return false; } } } ?> i am having issues checking which value is checked in a form. here is my code for it: Code: [Select] <input type="radio" name="accountActivation" id="no" value="no" checked=" <? if (isset($register_errors)) { if (($_POST['accountActivation']) == "no") { echo "checked"; } } ?> " /> when i first open the page, no is checked. why is this, when there should be no errors, and the radio should not even be checked in the first place? i have a form, and if the form has not been sent, it shows the form. here is my code for the beginning: Code: [Select] if($sent != true) { echo" ?> <div class='form'><form action='' method='post'> [b]!!![/b] <p class='form'>User ID: <br /><input name='memberID' type='hidden' value='<?php echo $row['id'] ?>' /> Your User ID will be logged for identity purposes. <br /><input type='checkbox' name='noIdentity' id='noIdentity' value='noIdentity' <?php if(isset($_POST['errors']) && isset($_POST[noIdentity])) { [b]!!![/b] echo ' checked='checked '"; } ?> /> and the end: Code: [Select] <?php "; } ?> it doesn't like what i have the exclamations next to. also, am i doing this right? hi all, I have a piece of code which I coded where it selects all there cars out of the database and shows them, well it is meant to: $getall = mysql_query("SELECT car, id FROM garage WHERE owner='$username'"); $gotall = mysql_fetch_object($getall); echo "$gotall->car - $gotall->id<br />"; Its meant to echo out all the cars which the user own, but for some reason its only echoing one car. Can anyone see why its only showing one car with the id not all the cars they own? Thanks. Hi all, On my website I have a Functions file which holds information about the user for the game, but earier on today I added ranks which are for the users money. So for the ammout of money they have gives them a different money rank. Heres what ive got: function wealthrank(){ if (($info->money >= "0") && ($info->money < "10000")){ $wealth = "Poor (£0 - £10,000)"; $done="1"; } elseif (($info->money >= "10000") && ($info->money < "500000")){ $wealth = "Won The Lottery (£10,000- £500,000)"; $done="1"; } elseif (($info->money >= "500000") && ($info->money < "5000000")){ $wealth = "Too Much (£500,000 - £5,000,000)"; $done="1"; } elseif (($info->money >= "5000000") && ($info->money < "20000000")){ $wealth = "Millionare (£5,000,000 - £20,000,000)"; $done="1"; } elseif (($info->money >= "20000000") && ($info->money < "75000000")){ $wealth = "Owns The Streets (£20,000,000 - £75,000,000)"; $done="1"; } elseif (($info->money >= "75000000") && ($info->money < "100000000")){ $wealth = "Won The Euro Millions (£75,000,000 - £100,000,000)"; $done="1"; } elseif (($info->money >= "100000000") && ($info->money < "300000000")){ $wealth = "Multi millionare (£100,000,000 - £300,000,000)"; $done="1"; } elseif (($info->money >= "300000000") && ($info->money < "700000000")){ $wealth = "Owns A Bank (£300,000,000 - £700,000,000)"; $done="1"; } elseif (($info->money >= "700000000") && ($info->money < "1500000000")){ $wealth = "Rather Rich (£700,000,000 - £1,500,000,000)"; $done="1"; } elseif (($info->money >= "1500000000") && ($info->money < "5000000000")){ $wealth = "Billionare (£1,500,000,000 - £5,000,000,000)"; $done="1"; } elseif (($info->money >= "5000000000") && ($info->money < "70000000000")){ $wealth = "Owner Of The Land (£5,000,000,000 +)"; $done="1"; } elseif ($info->money >= "100000000000"){ $wealth = "Nearly As Rich As NoName (Hidden!)"; $done="1"; } if (!$done){ $done="0"; } if ($done == "1"){ mysql_query("UPDATE users SET wealthrank='$wealth' WHERE username='$username'"); }} wealthrank(); For some reason its not echoing the correct wealth rank, even at that its only echoing the defult wealth rank. Here is what I done to test it. <?php session_start(); include ("includes/functions.php"); include ("includes/config.php"); logincheck(); $username = $_SESSION['username']; $get = mysql_query ("SELECT * FROM users WHERE username='$username'"); $fetch = mysql_fetch_object($get); ?> Testing something: <?php echo ($username); ?><br /> Wealth Rank: <?php echo ($fetch->wealthrank); ?><br /> Is there something wrong with the way im fetching it from the Database or something wrong with the code? Thanks for any help given. i'm not sure whether this should be in this section or the ajax section. i'm trying to echo out an ajax script so that a page loads in a div tag after a link is clicked in the menu. Without the "echo", it works fine, but as soon as i include it within the "echo", it stops working. Any help would be great else echo" <div id='fcontrol'> <table border='1' class ='tstyle'> <tr height ='700'><td valign='top' class='ssbg' width='120'><div id='menu'> <a href='javascript:ajaxpage(''new_section.php'', ''contentarea'');'>Add new section</a><br/><br/> <a href='javascript:ajaxpage('new_sub_section.php', 'contentarea');'>Add new section to forum</a><br/><br/><a href='index.php'>Back to forum</a><br/><br/></div></td><td class='tcontrol' width='700' valign='top'> <center><div id='contentarea'>Control Panel</div></center></td></tr> </table></div> </div> "; ?> I have a login form at http://cloydprojects.com you can login with username: test password test If you login the script works correctly, but if you type in the wrong info my session is not showing here is that I have. my login script Code: [Select] <?php session_start(); ?> <link href="signUp.css" rel="stylesheet" type="text/css" /> <?php include("db.php"); include("classes/class.account.php"); $Acc = new account; $u = $Acc->clean($_REQUEST['usernameLogin']); $password = $Acc->clean($_REQUEST['passwordLogin']); $p = md5($password); $get = mysql_query("SELECT * FROM users WHERE username = '".$u."' and password = '".$p."'"); $find = mysql_num_rows($get); if ($find == 1) { $info = mysql_fetch_assoc($get); $_SESSION['LoggedIn'] = $info['uID'].'.'.$info['username'].'.'.$info['email']; } else { $_SESSION['LoggedFailed'] = '<div id="ErrorBox">Incorrect username/password!</div>'; } //there is more just not showing it here is my index script where the error should be showing! Code: [Select] <div class="stylized"> <?php if(isset($_SESSION['LoggedIn'])) { echo '<h1> Welcome! </h1>'; echo '<a href="logout.php">logout!</a>'; } else { echo $_SESSION['LoggedFailed']; session_destroy(); ?> <form id="instantform" name="form" action="loginUser.php" method="post"> <h1>Login</h1> <label>Username <span class="small">The username you created!</span></label> <input type="text" name="usernameLogin" id="usernameLogin" /> <label>Password <span class="small">Case sensitive!</span></label> <input type="password" name="passwordLogin" id="passwordLogin" /> <button type="submit">Login</button></div> <div class="spacer"></div> </form> <?php } ?> </div> |