PHP - Php Error Reporting Level
When I use ini_get to check my error_reporting level, I get a weird value ( 4983 ) that I can't find anywhere by googling.
Also not on the list of possible levels here ( http://itech.hubpages.com/hub/php-error_reporting ) .. does anyone know how to determine what exactly this level is? Thanks! Similar TutorialsI want to log my errors to a log file but it isn't working. I get the error displayed on the screen but the file is not written to. The file permissions are set to 777 to make things easy. Error reporting is on for development only. Any advice on why I cannot write to the file? It's an apache server. Is there a trick to getting the file path correct relative to my front controller? Also, if I use error_log to send the error to my email address, it works. ini_set('error_reporting', E_ALL | E_STRICT); ini_set('display_errors', true); error_log("You messed up!", 3, '/var/www/vhosts/domain.com/httpdocs/framework/errors.txt'); im getting this error when i run a script mysql_query(): supplied argument is not a valid MySQL-Link resource what do i have to do to echo out the actual error and what line its on like this Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/www/ikhelper.freehostia.com/globinc/loginfunc.php on line 87 iv tried inserting error_reporting(E_ERROR | E_WARNING | E_PARSE); and error_reporting(-1); but doesnt output any error I have been working on this awhile (the perfect PHP error handling for my coding style). I have tried to set it up as: Code: [Select] <?php error_reporting(E_ALL & E_STRICT & ~(E_NOTICE)); ?> I want this to show me E_ALL errors, E_STRICT errors, and NOT show me E_NOTICE. Is this the right way to set that up, or am I doing something wrong. I haven't used E_STRICT before but I am anxious to see what kind of errors that have it showing since I haven't messed with it before. Thanks again. Hi Guys Completely Stuck by this one. Using the code below, when I go to the page I am getting a completely blank page (even though I have Error Reporting on. Can anybody tell me where I have gone wrong? Code: [Select] <?php ini_set ('display_errors', 1); error_reporting(E_ALL); ?> <?php session_start(); include_once('includes/connect_inc.php'); include_once('functions/reg_functions.php'); ?> <!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"><!-- InstanceBegin template="/Templates/trade-bidz.dwt.php" codeOutsideHTMLIsLocked="false" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <!-- InstanceBeginEditable name="doctitle" --> <title>Trade-Bidz Coming Soon...</title> <!-- InstanceEndEditable --> <!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable --> <link href="style/trade-bidz.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" language="JavaScript"> <!-- Copyright 2006,2007 Bontrager Connection, LLC // http://bontragerconnection.com/ and http://www.willmaster.com/ // Version: July 28, 2007 var cX = 0; var cY = 0; var rX = 0; var rY = 0; function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;} function UpdateCursorPositionDocAll(e){ cX = event.clientX; cY = event.clientY;} if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; } else { document.onmousemove = UpdateCursorPosition; } function AssignPosition(d) { if(self.pageYOffset) { rX = self.pageXOffset; rY = self.pageYOffset; } else if(document.documentElement && document.documentElement.scrollTop) { rX = document.documentElement.scrollLeft; rY = document.documentElement.scrollTop; } else if(document.body) { rX = document.body.scrollLeft; rY = document.body.scrollTop; } if(document.all) { cX += rX; cY += rY; } d.style.left = (cX+10) + "px"; d.style.top = (cY+10) + "px"; } function HideContent(d) { if(d.length < 1) { return; } document.getElementById(d).style.display = "none"; } function ShowContent(d) { if(d.length < 1) { return; } var dd = document.getElementById(d); AssignPosition(dd); dd.style.display = "block"; } function ReverseContentDisplay(d) { if(d.length < 1) { return; } var dd = document.getElementById(d); AssignPosition(dd); if(dd.style.display == "none") { dd.style.display = "block"; } else { dd.style.display = "none"; } } //--> </script> </head> <body> <div id="header"> <div id="login_form"> <?php //if(!isset($_SESSION['logname'])) //{ //include_once('includes/mini_login_inc.php'); //} //else //{ //include_once('includes/logout_inc.php'); //} ?> </div> <img src="images/logo.jpg" width="300" /></div> <div id="nav_head"><ul><li>Buying</li><li>Selling</li><li>Contact Us</li><li>Terms</li><li>My Trade-Bidz</li></ul></div> <div id="content"><!-- InstanceBeginEditable name="content" --> <form name="add_lot" action="add_vehicle.php" method="post"> <table> <tr><td>Reg Number</td><td><input name="veh_reg" width="10" maxlength="10"/><img src="images/search_glass.jpeg" width="50" onclick="getVehData()" /> <?php if (isset($message)) { echo ('<br />'.$message.); } ?> </td></tr> </table> </form> </body> <!-- InstanceEnd --></html> I am using the classic Code: [Select] ini_set("display_errors","2"); ERROR_REPORTING(E_ALL); but I am getting a notice that is posting on my page. I preffer not to remove the reporting yet since the site is still new and is there any way I can hide the notice but keep the fail errors the error is Code: [Select] Notice: Undefined index: HTTPS in /var/www/website/visitors.php on line 20 line 20 is Code: [Select] if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} hey all,
I've finally took a leap towards the brighter side of coding.. and Ive started to convert my code from php to opp pdo ect..
However the errors Ive been through my cms's and well anything to do with inserting into a database is rather confusing..
ERRORS such as invalid parameter number,.
What does this mean?
Here's the code that im getting the error from:
<?php //if form has been submitted process it if(isset($_POST['submit'])){ $_POST = array_map( 'stripslashes', $_POST ); //collect form data extract($_POST); //very basic validation if($title ==''){ $error[] = 'Please enter the title.'; } if($short_desc ==''){ $error[] = 'Please enter a short description.'; } if($full_desc ==''){ $error[] = 'Please enter a full description.'; } if(!isset($error)){ try { //insert into database $stmt = $handler->prepare('INSERT INTO calendar_event (title,short_desc,full_desc,date) VALUES (:title, :short_desc, :full_desc, :date)') ; $stmt->execute(array( ':title' => $title, ':short_desc' => $short_desc, ':ful_desc' => $full_desc, ':date' => date('Y-m-d') )); //redirect to index page header('Location: index.php?action=added'); exit; } catch(PDOException $e) { echo $e->getMessage(); } } } //check for any errors if(isset($error)){ foreach($error as $error){ echo '<p class="error">'.$error.'</p>'; } } ?> <form action='' method='post'> <table class="admin_table_defaults"> <tr> <th width="10px">Title</th> <th width="200px">Date</th> <th width="200px"> </th> <th></th> </tr> <tr> <td><input type='text' name='title' value='<?php if(isset($error)){ echo $_POST['title'];}?>'></td> <td><input type='date' name='date' value='<?php if(isset($error)){ echo $_POST['date'];}?>'></td> <td><td> </tr> </table> <table class="admin_table_defaults"> <tr> <th style="text-align:left;"> Short Description <span class="small_text"> : NB - Please avoid using images, align properties, stick to text format. <br/><b style="background:#fff;font-size:14px;">Note : There's a character max of 100 characters for this field</b></span></th> </tr> <tr> <td><textarea name='short_desc' cols='60' rows='10' ><?php if(isset($error)){ echo $_POST['short_desc'];}?></textarea></td> </tr> <tr> </table> <table class="admin_table_defaults"> <tr> <th style="text-align:left;"> Full Description: <span class="small_text"></th> </tr> <tr> <td><textarea name='full_desc' cols='60' rows='10'><?php if(isset($error)){ echo $_POST['full_desc'];}?></textarea></td> </tr> <tr> <td><input class="admin_submit_btn"type='submit' name='submit' value='Submit'></td> </tr> <tr> </table> </tr> </table> </form>Any help will be greatly appreciated Thanks in advance.. Hello everyone, I have a messaging site where I have an email generated every night to report new activity on my site. The way it is currently set up, I have each message reply attached to the previous message, such as quoting the original text in an email message. Each string of messages in my database has one common field ("string"), but each new reply has a different message ID field in the database ("messid"). When each new message and reply is created the "reported" field in my database has a default value of n, meaning that it has not been reported yet. At the end of the day, when the email is generated, the reported field is then updated to y, meaning that it HAS been reported. The problem that I'm having now, is that I'm getting several of the same messages in every report. I am using the following code to select each unreported message from the database to generate my report: Code: [Select] <?php $result = mysql_query("SELECT `to`,`studentname`,`staffname`,`subject`,`message`,`date` FROM caresa6_$acct.allmsgs WHERE reported = 'n' ORDER BY `messid` ASC") or die (mysql_error()); ?> Basically, I need to know how to select only the most recent unreported message within each string of messages. For example, now if there is a new message: "Hello there." Then a reply from the recipient: "Hi! How are you?" Then another reply from the original sender: "I am fine." My report will look like this: ___________ New Message: "Hello there." ------------------ Reply: "Hi! How are you?" ------------------ Reply: "I am fine." ------------------ ___________ New Message: "Hello there." ------------------ Reply: "Hi! How are you?" ------------------ ___________ New Message: "Hello there." ------------------ So I am getting carbon copies of every new message every time someone replies. I want to only select the most recent message so that my report only reads: ___________ New Message: "Hello there." ------------------ Reply: "Hi! How are you?" ------------------ Reply: "I am fine." ------------------ Thanks in advance. Hi , Presently we are preparing an excel for download report by querying to data base. We are querying to DB and looping through each result row and writing to excel. for 2lacs data its too much time. I found the time taken max in DB query and processing the DB data . Ant way I can make it faster ? Any parallel processing I can apply to get it faster......I expecting Huge data report in future. My form Code: [Select] <form action="process.php" method="post"> <font face= "calibri" size= "4"> <table border= "1"> <tr style= "background: #cccccc"> <td><b>Item Description:</b></td> <td><input type= "text" name= "itemDescription" size= "30" value=""/></td> </tr> <tr style= "background: #99ff00"> <td><b>Item Price:</b></td> <td><input type= "text" name= "itemPrice" size= "5" value=""/></td> </tr> </tr style= "background: #A8E5FF"> <td><b>Winning Bidders:</b></td> <td><input type="text" name= "winningBidder" size= "5" /> </td> </tr> <tr> <td><b>How many deals?:</b></td> <td><input type="text" name= "itemQty" size= "3" value= "1" /></td> </tr> </table> <br/> <input type="reset" value="Reset Form"><input type="submit" name="submit" value= "Save & Cont." " /> </form></font> My process script: Code: [Select] <?php error_reporting(E_ALL); ini_set("display_errors", 1); $host= ""; $db_name= ""; $db_user= ""; $db_password= ""; $logUser= $_POST['logUser']; $deleteBidder = $_POST['deleteBidder']; $newBidder= $_POST['newBidder']; $itemDescription= $_POST['itemDescription']; $itemPrice= $_POST['itemPrice']; $winningBidder= $_POST['winningBidder']; $itemQty= $_POST['itemQty']; ob_start(); if ($_POST['newBidder']) { $bidderId= $newBidder; mysql_connect("$host", "$db_user", "$db_password")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM bidders WHERE biddersId='$bidderId'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==0){ // Add $biddersId and redirect to anypage mysql_Query("INSERT INTO bidders (biddersId) VALUES ('$bidderId')"); header("Location: index.php"); exit(); } } if ($_POST['deleteBidder']) { mysql_connect("$host", "$db_user", "$db_password")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB"); mysql_query("DELETE FROM bidders WHERE biddersId='$deleteBidder'"); header("Location: index.php"); exit(); } if ($_POST['itemDescription'] AND $_POST['itemPrice'] AND $_POST['winningBidder'] AND $_POST['itemQty']) { mysql_connect("$host", "$db_user", "$db_password")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM transactions WHERE biddersId='$winningBidder'"; $result=mysql_query($sql); $count=mysql_num_rows($result); // If result matched, table row must be 1 row if($count==0){ echo "That Bidder Number is NOT logged in, "; echo "would you like to set this bidder as active?"; echo " Enter 1 for NO or 2 for YES"; echo "<form action= \"process.php\" method= \"POST\">"; echo "<input type =\"text\" name= \"logUser\"/>"; echo "<input type= \"submit\" value = \"Submit\"/>"; $logUser= $_POST['logUser']; exit(); } if ($logUser= 1) { header("Location: inprogress.php"); exit(); } else if ($logUser= 2){ // Add $biddersId and redirect to anypage mysql_connect("$host", "$db_user", "$db_password")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB"); mysql_Query("INSERT INTO bidders (biddersId) VALUES ('$winningBidder')"); mysql_query("INSERT INTO transactions (itemDescription, itemPrice, bidderId, itemQty , totalPrice) VALUES('$itemDescription', '$itemPrice','$winningBidder', '$itemQty', '$totalPrice')") or die(mysql_error()); $_SESSION['itemDescription']='$itemDescription'; header("Location: index.php"); exit(); } } echo "<font color= \"red\" face=\"calibri\" size=\"4\">That bidder is already logged, Please press your browsers back button and try again.</font>"; ob_end_flush(); ?> DeleteBidder and newBidder are the only variables working? I am trying to echo out an array from my data base. I think I have my function created correctly: Noted below is the snippet from my transaction.class.php file Code: [Select] <?php //Retreives data from the database public function retrieve_all_data($TransactionDate=0, $TransactionType=0, $TransactionAmount=0, $CurrentBalance=0){ $accounts_query = "SELECT TransactionDate, TransactionType, TransactionAmount, CurrentBalance FROM BankAccount, TransactionType, TransactionLog = " . $this->accountid ." LIMIT 0,30"; $result = mysqli_query($this->connection, $accounts_query); return $result; } ?> I try to echo out using this format but I am not having any luck. Code: [Select] <?php /*Accounts*/ $currentMember->connection = $conn; $accounts = $currentMember->retrieve_all_data(); /*Loop through account - Grabs data*/ while($account = mysqli_fetch_assoc($accounts)){ /*Retrieve Balance*/ $transaction = new Transaction($account['TransactionDate'], $account['TransactionType']); $transaction->connection = $conn; //$balance = mysqli_fetch_assoc($transaction->retrieve_current_balance()); echo '<tr>' . "\n"; echo "\t" . '<td>' . $account['TransactionDate'] . '</td>' . "\n"; echo "\t" . '<td>' . $account['TransactionType'] . '</td>' . "\n"; echo '<tr>' . "\n"; } /*Close DB*/ mysqli_close($db->connection); ?> Hi,
Can anyone recommend some Business Intelligence tools that can be integrated into a PHP (wordpress/joomla) based website? I've had a good look around the net but they all seem to be written in Java/J2EE and appear to be software based - not sure if im after the possible or impossible here...
Thanks
Hi - I've got a program to allow the user to upload a file and then select, for each column of an existing table, the column from the new source table to insert. However, what I need to do is do the insert using the actual names, but show the user a drop-down menu of the LABELS they've chosen for each of these real, target columns. Is there a "clean" or "tricky" way of doing this? The code to do the inserts works by just reading the translation table that has two columns -- source column fieldname and target column (in the existing table) fieldnames (both real fieldnames, of course). Here's what I've got: <form action="index.php" method="post"> <input type="hidden" id="unique" name="unique" value="<?php echo $unique_nm; ?>" /> <input type="hidden" id="savetotable" name="savetotable" value="1" /> <?php foreach($LabelList as $c_name){ ?> <div> <div style="float: left; width: 300px;"; > <?php echo $c_name; ?> </div> <div style="float: left; width: 400px;"> <select id="<?php echo $c_name; ?>" name="<?php echo $c_name; ?>"> <option value=""></option> <?php foreach($SourceColumns as $h_name){ ?> <option value="<?php echo trim($h_name); ?>"> <?php echo trim($h_name); ?> </option> <?php } ?> </select> </div> <div style="clear: both;"></div> </div> <?php } ?> <input type="submit" value="Save to Database" /> </form> So, while I could load the data into the targetfile pretty easily using the real target table column names, how can I present the user with a drop-down menu of LABELS, but insert the data into the REAL target fields? Here's the list of ACTUAL fields: $output = array(); $gather = 'select FieldName from MapTable where User = UserID' $this->call($gather); foreach($this->data as $row){ $ActualFields[] = $row['COLUMN_NAME']; } return $ActualFields; } Here's the list of LABELS (phony field names): $output = array(); $gather = 'select LabelName from MapTable where User = UserID' $this->call($gather); foreach($this->data as $row){ $LabelList[] = $row['COLUMN_NAME']; } return $LabelList; } The list of fields from the sourcefile the user is loading are all actual, real names ($SourceColumns) Hi, I would like to make a login page with 2 different user level, Admin & Staff. How can i do it using d code below. Thank u. <?php $host="localhost"; $username="root"; $password=""; $db_name="profile"; $tbl_name="company"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("Cannot Select Database"); // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); if($count==1){ session_register("myusername"); session_register("mypassword"); header("location:login_success.php"); } else { echo "Wrong Username or Password"; } ?> i try to create login page with two different user level for example admin and staff. i did not get any error on my code but it just did not direct to the page it been set to. it just display wrong username or password. i not really sure what is wrong. here is the code loginForm.php Code: [Select] <form action="login.php" method ="post"> <table> <tr><td>Usernama</td> <td><input name="username" type="text" size = "15" maxlength = "15"/></td></tr> <tr><td>Password</td> <td><input name="password" type="password" size = "15" maxlength = "15"/></td></tr> </table> <br><input name="submit" type ="submit" value ="Login"/></td> </form> login.php Code: [Select] <?php ob_start(); $host="localhost"; $user="root"; $pass=""; $db_name="office"; $tbl_name="login"; mysql_connect("$host", "$user", "$pass")or die("cannot connect"); mysql_select_db("$db_name")or die("Cannot Select Database"); // username and password sent from form $sername=$_POST['username']; $password=$_POST['password']; $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $sql="SELECT * FROM daftarPenyelia WHERE user='$username' AND pass='$password' AND userLevel='$userLevel'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); if ($count == $userLevel) { if ($userLevel == 1) { $_SESSION['username'] = $username; $_SESSION['password'] = $password; header("location:adminMenu.php"); } else if ($userLevel == 2) { $_SESSION['username'] = $username; $_SESSION['password'] = $password; header("location:staffMenu.php"); } } else { echo "Wrong Username or Password"; } ?> can someone help me with this code and tell me what is wrong so that i can fix them Hi all I have a menu function which basically produces a menu which looks like Code: [Select] Products Apple iMac iPod iPhone Microsoft Windows Office and the code I use is; THE FUNCTION function menu($parentID, $mymenu) { $html = ""; if (isset($mymenu['parentID'][$parentID])) { $html .= " <ul>\n"; foreach ($mymenu['parentID'][$parentID] as $menu_id) { if(!isset($mymenu['parentID'][$menu_id])) { $html .= "<li>\n <a href='/".$mymenu['menu_item'][$menu_id]['url']."'>".$mymenu['menu_item'][$menu_id]['value']."</a>\n</li>"; } if(isset($mymenu['parentID'][$menu_id])) { $html .= "<li>\n <a href='/".$mymenu['menu_item'][$menu_id]['url']."'>".$mymenu['menu_item'][$menu_id]['value']."</a>"; $html .= menu($menu_id, $mymenu); $html .= "</li>"; } } $html .= "</ul>"; } return $html; } CREATE MENU CODE $result = mysql_query("SELECT id, value, url, parentID FROM menu WHERE active = 1 AND deleted = 1 ORDER BY position ASC"); $mymenu = array('menu_item' => array(),'parentID' => array()); while ($menu_item = mysql_fetch_assoc($result)) { $mymenu['menu_item'][$menu_item['id']] = $menu_item; $mymenu['parentID'][$menu_item['parentID']][] = $menu_item['id']; } echo menu(0, $mymenu); The problem I have is the URLS, at the moment the menu URLS are outputted as Code: [Select] Products - http://localhost/Products Apple - http://localhost/Apple iMac - http://localhost/iMac iPod - http://localhost/iPod But I need to alter my function so that URLS are outputted as Code: [Select] Products - http://localhost/Products Apple - http://localhost/Products/Apple iMac - http://localhost/Products/Apple/iMac iPod - http://localhost/Products/Apple/iPod Is this at all possible? Thanks very much everyone John Hi All, I have a function that creates an array using a few sql quereys. I then use the array to output to html. I am wanting to add more data to the array to populate another column in the created table. I am unsure how to add $miqty to the array and then output it in the Qty On Order column. I feel like i need to add the [] to $menuItemsInCat[$mcatname][$miid] = $miname; section but i am not sure where in there it should be.
<?php if (session_status() == PHP_SESSION_NONE) { session_start(); } if (!isset($_SESSION['user_id'])){ header("location: index.php"); exit; } //name of the pagea $_SESSION['this_page'] = 'new-menu'; function getMenuItems($conn){ $output = ''; $stmt = $conn -> query(" SELECT menu_category_name FROM ssm_menu_items INNER JOIN ssm_menu_category on menu_item_category_id = menu_category_id ORDER BY menu_category_display_order "); //create an empty array of all of the menu categories that are in use foreach ($stmt as $item){ $menuItemsInCat[$item['menu_category_name']] = []; } $stmt = $conn -> prepare(" SELECT menu_item_id, menu_item_name, menu_category_name, sum(menu_item_qty) FROM ssm_menu_items mi INNER JOIN ssm_menu_category mcat ON mi.menu_item_category_id = mcat.menu_category_id left join ssm_menu_order USING (menu_item_id) GROUP BY menu_item_id "); $stmt -> execute(); $stmt -> bind_result($miid, $miname, $mcatname, $miqty); while ($row = $stmt -> fetch()) { //put items into the blank array created above under their correct category $menuItemsInCat[$mcatname][$miid] = $miname; } echo "<pre>"; print_r($menuItemsInCat); echo "</pre>"; //foreach thing in $menuItemInCat array there is $menucat array associated with $menuit(ems) array //we want the menu cat foreach ($menuItemsInCat as $menucat => $menuit) { $output .= "<tbody>"; $output .= "<tr class='bg-secondary text-white text-center'><th>$menucat</th>"; $output .= "<th>Qty On Order</th><th>Manage</th></tr>"; //foreach thing in menu items array there is an array of ids and an array of items foreach ($menuit as $itemId => $itemName) { $output .= "<tr><td>$itemName</td>"; $output .= "<td></td>"; $output .= "<td><div class='btn btn-primary'>Manage</div></td></tr>"; } $output .= "</tbody>"; } return $output; } ?> <?php include '_includes/head.php'; ?> <div class="container-fluid"> <div class="row"> <?php include '_includes/header.php'; ?> </div> <div class="row" > <div class="col-sm-2 p-0 bg-dark text-light"> <?php include '_includes/nav.php'; ?> </div> <div class="col-sm-10" style="height: calc(100vh - 80px);overflow:scroll;"> <div class="mt-3"> <table class="table table-striped table-hover table-bordered text-center align-middle"> <?= getMenuItems($conn) ?> </table> </div> <div class="col-sm-12"><?php include '_includes/footer.php'; ?></div> </div> </div> </div> <script> //set sidebar active indicator //XX = name of parent if in dropdown eg "sheet" if(document.getElementById('menu')){ document.getElementById('menu').classList.add('show') } //nav button ID if(document.getElementById('newMenu')){ document.getElementById('newMenu').classList.add('blOrange') } </script> As always your help is very appreciated. Edited February 5, 2020 by AdamhumbugHello. Basically I have created a form that you fill in and an email gets sent to your in box and you have an access_level of 1. Within this email there is one field. A validation_id. Now what im trying to do is when you click this link it opens the webpage and updates your access_level to 2. I have wrote my query and array and i can see exactly which bit is wrong. Its where i have validation_id= $validation_id") Now its not working and I can see the error. Problem is im too new at this to understand why its wrong and how to fix it can anyone help? Here is the rest of the code. Also could you please explain? I would really like to understand it before i move any further. p.s. I have already selected my database in the included file <? include('database_name'); session_start(); $validation_id =$_GET['validation_id']; $FullRec__query=sprintf("SELECT * FROM Members WHERE validation_id= $validation_id"); $FullRec = mysql_query($FullRec__query, $database name) or die(mysql_error()); $FullRecArray = mysql_fetch_array($FullRec); $UdateAccessQuery = sprintf("UPDATE Members SET access_level = '2' WHERE validation_id = $validation_id"); mysql_query($UdateAccessQuery, $database_name) or die(mysql_error()); ?> In javascript you can do multiple methods on the same line like: if(document.getElementById('myElement').className.match(/^[0-9]/)){/*Do something*/} in that we have getElementById() and match() on the same line, and it works the same as if you were to split them on multiple lines. Is it possible to do that with php? For example: $obj = new MyObject(); $obj->add(2, 3)->to_string(); Hello everybody, i am working on n level category tree structure, for your information the category tree structure image is attached with this post. Let's consider, each of the category have hundreds( n level ) of category in each, i want to traverse each category without using recursive functions, reason being recursive functions are very slow, is there any way to do this?? Thanks, phpeid Hi everyone, I'm very new to PHP and have been following Kevin Yank's "How to build a db driven website using php & mysql" 3rd ed. and am working through Chapter 6, where a basic search page is created. What I would like to be able to do is, in the results, display not only the joketext (as done in the book), but also the author's name (which is located in a different table in the db), as well as the date it was submitted (in the same db as joketext), possibly a link to another site and extra info like the joke category. In general, I would like to be able to understand how to adjust the php code to add data related to the results of any given search. The information is already related through the database, how do I use it in the results of a search? I've used the same names of variables and tables as used in the book. Thank you in advance for any help you can offer! I really appreciate it. Below is the code for the part of the code I would like to change (highlighted parts) followed by the code for whole page (2 main sections "search" and "results". In the main code, the excerpt below is located a few lines from the bottom (in "results"): Note: the only variable currently displaying in the results in $joketext (also highlighted). Ok, enough explaining! /////////// EXCERPT : PART I WANT TO DISPLAY DIFFERENTLY ////////////// <?php echo "<li id=\"jump\"> <article class=\"entry\"> <header> <h3 class=\"entry-title\"><a href=''$VAR for email or weblink from author table">$VAR for author name from author table</a></h3> </header> <div class=\"entry-content\"> <p>$joketext</p></div> <footer class=\"entry-info\"> <abbr class=\"published\" title=\"2011-09-22T14:07:00-07:00\">$VAR for date uploaded in joke table</abbr> <p>$VAR for joke category from jokecategory table</p> </footer> </article> </li>"; } ?> //////////////////////////// MAIN CODE /////////////////////// <html> <body> . <header></header> . <section id="search"> <?php $dbcnx = @mysql_connect('localhost', 'root', 'password'); if (!$dbcnx) { exit('<p>Unable to connect to the ' . 'database server at this time.</p>'); } if (!@mysql_select_db('ijdb')) { exit('<p>Unable to locate the joke ' . 'database at this time.</p>'); } $authors = @mysql_query('SELECT id, name FROM author'); if (!$authors) { exit('<p>Unable to obtain author list from the database.</p>'); } $cats = @mysql_query('SELECT id, name FROM category'); if (!$cats) { exit( '<p>Unable to obtain category list from the database.</p>'); } $themes = @mysql_query('SELECT id, name FROM theme'); if (!$themes) { exit( '<p>Unable to obtain category list from the database.</p>'); } $geofoci = @mysql_query('SELECT id, name FROM geofocus'); if (!$geofoci) { exit( '<p>Unable to obtain category list from the database.</p>'); } ?> <form class="searchField" name="input" action="main_search.php#jump" method="post"> <input type="text" name="searchtext"> <input type="submit" value="Search"> <ul> <li> <label><select name="aid" size="1"> <option selected value="">Any Author</option> <?php while ($author = mysql_fetch_array($authors)) { $aid = $author['id']; $aname = htmlspecialchars($author['name']); echo "<option value='$aid'>$aname</option>\n"; } ?> </select></label> </li> <li> <label><select name="cid" size="1"> <option selected value="">Any Category</option> <?php while ($cat = mysql_fetch_array($cats)) { $cid = $cat['id']; $cname = htmlspecialchars($cat['name']); echo "<option value='$cid'>$cname</option>\n"; } ?> </select></label> </li> <li> <label><select name="tid" size="1"> <option selected value="">Any Theme</option> <?php while ($theme = mysql_fetch_array($themes)) { $tid = $theme['id']; $tname = htmlspecialchars($theme['name']); echo "<option value='$tid'>$tname</option>\n"; } ?> </select></label> </li> <li> <label><select name="gfid" size="1"> <option selected value="">Any Region</option> <?php while ($geofocus = mysql_fetch_array($geofoci)) { $gfid = $geofocus['id']; $gfname = htmlspecialchars($geofocus['name']); echo "<option value='$gfid'>$gfname</option>\n"; } ?> </select></label> </li> <li><a href="">Closing Date</a></li> </ul> </form> </section> <section id="results"> <?php $dbcnx = @mysql_connect('localhost', 'root', 'password'); if (!$dbcnx) { exit('<p>Unable to connect to the ' . 'database server at this time.</p>'); } if (!@mysql_select_db('ijdb')) { exit('<p>Unable to locate the joke ' . 'database at this time.</p>'); } // The basic SELECT statement $select = 'SELECT DISTINCT id, joketext'; $from = ' FROM joke'; $where = ' WHERE 1=1'; $aid = $_POST['aid']; if ($aid != '') { // An author is selected $where .= " AND authorid='$aid'"; } $cid = $_POST['cid']; if ($cid != '') { // A category is selected $from .= ', jokecategory'; $where .= " AND joke.id=jokecategory.jokeid AND categoryid='$cid'"; } $tid = $_POST['tid']; if ($tid != '') { // A theme is selected $from .= ', joketheme'; $where .= " AND joke.id=joketheme.jokeid AND themeid='$tid'"; } $gfid = $_POST['gfid']; if ($gfid != '') { // A region is selected $from .= ', jokegeofocus'; $where .= " AND joke.id=jokegeofocus.jokeid AND geofocusid='$gfid'"; } $searchtext = $_POST['searchtext']; if ($searchtext != '') { // Some search text was specified $where .= " AND joketext LIKE '%$searchtext%'"; } ?> <ol id="results-list"> <?php $jokes = @mysql_query($select . $from . $where); if (!$jokes) { echo '</table>'; exit('<p>Error retrieving jokes from database!<br />'. 'Error: ' . mysql_error() . '</p>'); } while ($joke = mysql_fetch_array($jokes)) { $id = $joke['id']; $joketext = htmlspecialchars($joke['joketext']); echo "<li id=\"jump\"> <article class=\"entry\"> <header> <h3 class=\"entry-title\"><a href=''>variable title</a></h3> </header> <div class=\"entry-content\"> <p>$joketext</p></div> <footer class=\"entry-info\"> <abbr class=\"published\" title=\"2011-09-22T14:07:00-07:00\">Sept. 22, 2011</abbr> </footer> </article> </li>"; } ?> </ol> </section> . <footer></footer> . . </body> </html> |