PHP - Why Are 5 Of My 7 Variables Reporting As Undefined? I'm Lost......
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? Similar TutorialsHello all, I just wrote a php website to communicate with a database and it has a login based on the users email and password, they login on the first page and then the php checks for every page they visit if they indeed logged in before and not just found out what php file to open to get where they want to be. For this I used session variables to store both e-mail and password. The login info gets posted from the 1st(login) site to the 2nd site where it is checked for the first time, after that the login info isn't posted to the next page anymore, but just checked, this works for the 3rd page but when the user hits for the 4th page the variables are lost(I can't echo them either). However if I'd go from the 2nd page directly to the 4th page the page will load, however the 5th will then get my security-msg. So offcourse, I am wondering how this might have happened and how to fix this problem, here's some of the code I wrote: This is the check for the logininfo: <?php include('SessionStart.php'); include('logindata.php'); $db = mysql_connect($host, $user, $pw); if (!$db) { echo "<br />Helaas, u heeft geen verbinding met de database."; exit(); } else { mysql_select_db("teammanagementtool", $db); $sql24 = "SELECT * FROM leidinggevenden"; $allesarray = mysql_query($sql24); $i = 0; while ($mails = mysql_fetch_array($allesarray)) { $mailtjes[$i] = $mails['lg_mailadres']; $i = $i+1; } echo "...".$_SESSION['sessie']['email']."...".$_SESSION['sessie']['password']."...".$session_name."..."; if (in_array($_SESSION['sessie']['email'],$mailtjes)) { $sql25 = "SELECT lg_wachtwoord FROM leidinggevenden WHERE lg_mailadres = '".$_SESSION['sessie']['email']."'"; $pass = mysql_query($sql25); $pasje = mysql_fetch_array($pass); if ($_SESSION['sessie']['password'] != $pasje['lg_wachtwoord']) { echo "<script>alert('U bent hier op incorrecte manier terecht gekomen!');</script>"; echo "<meta http-equiv='refresh' content='0;URL=index.php' />"; exit(); } else if ($_SESSION['sessie']['password'] = "" || $_SESSION['sessie']['email'] = ""){ echo "<script>alert('U bent hier op incorrecte manier terecht gekomen!');</script>"; echo "<meta http-equiv='refresh' content='0;URL=index.php' />"; exit(); } else { } } else { echo "<script>alert('U bent hier op incorrecte manier terechtgekomen!');</script>"; echo "<meta http-equiv='refresh' content='0;URL=index.php' />"; exit(); } ?> And this is the code in my SessionStart.php: <?php $session_name = 'sessie'; $session_exp_time = 10000 ; $previous_name = session_name($session_name); ini_set('session.gc_maxlifetime', $session_exp_time); ini_set('session.gc_probability', '1'); ini_set('session.gc_divisor', '1000'); ini_set('session.name', $session_name); ini_set('session.cookie_domain', ''); ini_set('session.cookie_lifetime', 0 ); session_set_cookie_params($session_exp_time, '/', ''); session_start(); if (isset($_COOKIE[$session_name])) setcookie($session_name, $_COOKIE[$session_name], 2147483647 , ''); ?> the includes are at the start of all of my pages, I only do a session_unset() at my index.php(the login page). and my 2nd page gets: $_SESSION['sessie']['email'] = $_POST['email']; $_SESSION['sessie']['password'] = $_POST['password']; from the login. I could really use some help here, thanks in advance. Hi, I have a feeling that this is going to be an easy miss but I've been over is a good few times and cannot see what it could be. Essentially, when I post the form in the first set of code (I've got rid of a load of unecessary html) the SESSION variables are not loaded into the second piece of code. Any ideas? Code: [Select] <?php session_start(); require ("connect.php"); $timeout = 1800; $logout_redirect_url = "login.php"; if (isset($_SESSION['start_time'])) { $elapsed_time = time() - $_SESSION['start_time']; if ($elapsed_time >= $timeout) { session_destroy(); header("Location: $logout_redirect_url"); } } $_SESSION['start_time'] = time(); ?> <div id="leftlink"> <a href="logout.php">Logout</a> </div> <table align="center" width="600px" cellpadding="0" cellspacing="0"> <tr> <td> <h2 align="center"><a href="index.php"><img src="images/logo.jpg" border="0" /></a> <br /> Emergency</h2> <hr /> </td> </tr> </table> </head> <body> <form action="post_reset.php" method="post" name"passre"> <table width="500" border="0" align="center" cellpadding="2" cellspacing="1"> <tr> <td width="230"><div align="right">E-mail Address : </div></td> <td width="40"> </td> <td width="230"><div align="left"> <input name="email" readonly="readonly" value="<?php echo ($_SESSION['email']) ; ?>" /></div></td> </tr> <tr> <td colspan="3"><div align="center"><input type="submit" name="submit" value="Submit" /></div></td> </tr> </table> </form> </body> </html> Code: [Select] <?php session_start; echo ($_SESSION['start_time']); require ("connect.php"); if (isset($_POST['submit'])){ $email = $_POST['email']; $getde = "SELECT * FROM users WHERE email = '$email'"; $getder = mysql_query($getde, $conn); $getdere = mysql_fetch_array($getder) Thanks Gareth I am trying to allow users of a web page the ability to create custom Excel exports. I have some code that I use elsewhere that works to make Excel exports. When I moved the code over to my custom report page, the Excel chart contains an error saying that $csv_output is undefined and so is $data (both variables toward the end of the page). I tried declaring the variables ($csv_output = ''; and $data = '' above the Excel code, but that didn't work. Can anybody help me out? Code below... Code: [Select] <?php //////////////////// INITIATE SESSION //////////////////// if (!isset($_SESSION)) { session_start(); } //////////////////// ALLOW ACCESS ONLY TO ADMINISTRATORS //////////////////// if ($_SESSION['person_priveleges'] == 0) { header("location:index.php"); } //////////////////// CONNECT AND SELECT DATABASE //////////////////// require_once('connect.php'); mysql_select_db($database, $connect); //////////////////// APPLY VARIABLES //////////////////// $state_search = ""; $payment_status = ""; $method_search = ""; //////////////////// GET USER SEARCH RESULTS //////////////////// if (array_key_exists('search', $_GET)) { // FILTER USER INPUT // // HERE // /////////////////////// // INITIALIZE ERROR ARRAY // $error = array(); // IF ALL INPUT FIELDS ARE LEFT BLANK THROW AN ERROR // if ((empty($_GET['state_search'])) && (empty($_GET['payment_status'])) && (empty($_GET['payment_method']))) { $error['search'] = "Please enter at least one search parameter."; // IF NO ERRORS START THE QUERY // } else { $search = "SELECT * FROM person"; // SET WHERE PART OF QUERY TO FALS SINCE WE DO NOT HAVE ANY WHERE PARAMETERS // $where = false; // IF THE PERSON SELECTS A STATE ASSIGN TO A VARIABLE AND ADD TO QUERY // if (isset($_GET['state_search']) && !empty($_GET['state_search'])) { $state_search = $_GET['state_search']; // FOR EACH STATE THAT WAS SELECTED // foreach ($state_search as $state) { // IF THERE ALREADY IS A WHERE CLAUSE ADD THE FOLLOWING CODE TO THE QUERY // if ($where) { $search .= " AND person_state = '$state'"; // IF THERE IS NO WHERE CLAUSE ADD THE FOLLOWING CODE TO THE QUERY AND SET WHERE TO TRUE SO FUTURE ADDITIONS WILL BE CORRECT // } else { $search .= " WHERE person_state = '$state'"; $where = true; } } } // IF THE PERSON SELECTS A PAYMENT STATUS ASSIGN TO A VARIABLE AND ADD TO QUERY // if (isset($_GET['payment_status']) && !empty($_GET['payment_status'])) { $payment_status = $_GET['payment_status']; foreach ($payment_status as $status) { if ($where) { $search .= " AND person_paid = '$status' "; } else { $search .= " WHERE person_paid = '$status' "; $where = true; } } } // IF THE PERSON SELECTS A PAYMENT METHOD ASSIGN TO A VARIABLE AND ADD TO QUERY // if (isset($_GET['payment_method']) && !empty($_GET['payment_method'])) { $payment_method = $_GET['payment_method']; foreach ($payment_method as $method) { if ($where) { $search .= " AND person_payment_method = '$method' "; } else { $search .= " WHERE person_payment_method = '$method' "; $where = true; } } } $search .= " AND person_priveleges = 0 ORDER BY person_last_name"; } $query_search = mysql_query($search, $connect) or die(mysql_error()); // CODE TO GENERATE EXCEL OUTPUT // // GET THE NUMBER OF FIELDS // $fields = mysql_num_fields($query_search); // FOR EACH RECORD IN THE DATABASE PRODUCE SOME OUTPUT // for ($i = 0; $i < $fields; $i++) { $csv_output .= mysql_field_name($query_search, $i) . "\t"; } while($row = mysql_fetch_row($query_search)) { foreach($row as $value) { if ((!isset($value)) OR ($value == "")) { $value = "\t"; } else { $value = str_replace('"', '""', $value); $value = '"' . $value . '"' . "\t"; } $line .= $value; } $data .= trim($line)."\n"; } $data = str_replace("\r","",$data); header("Content-Type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename=Registration Report for IDUES 2011 Project Directors Meeting.xls"); header("Pragma: no-cache"); header("Expires: 0"); print $csv_output."\n".$data; exit; } ?> Hi. I'm still very new to this forum, so i may be asking this the wrong way. I'm working on a project, but i keep running into the same wall. Whenever i try to load a page with a variable i named on another page, i get an error telling me that it does not know that variable. But how do i make it check for the variable before using it? Example of my code (i only show the first part, as it is the only one relevant): Code: [Select] <html><body> <?php session_start(); if($_SESSION['username']); { $username = $_SESSION['username']; As you can see i have tried to deal with it using an if statement, but i still get the error. I bet there is a very simple way to do this, but i cant see it right now. This is what I'm getting... Notice: Undefined variable: sitetitle in /home/vehiclep/public_html/functions.php on line 121 Notice: Undefined variable: ADcode in /home/vehiclep/public_html/functions.php on line 121 Notice: Undefined variable: email in /home/vehiclep/public_html/functions.php on line 121 Notice: Undefined variable: url in /home/vehiclep/public_html/functions.php on line 121 Notice: Undefined variable: charge in /home/vehiclep/public_html/functions.php on line 121 Notice: Undefined variable: currency in /home/vehiclep/public_html/functions.php on line 121 Notice: Undefined variable: price in /home/vehiclep/public_html/functions.php on line 121 this is functions.php Code: [Select] function sitesets() { $sql = "select * from settings limit 1"; $rs = mysql_query($sql); $row = @mysql_fetch_array($rs); extract($row); $sitesets = array("title"=>$sitetitle, "ADcode"=>$ADcode, "email" => $email, "url" => $url, "charge" => $charge, "currency" => $currency, "price" => $price); return $sitesets; } Ive tried going into phpMyadmin and creating a row and entering the info manualy but it doesnt work. I don't know much about coding so this may be a dumb question but it has me stumped. I hope somebody can tell me what I'm missing here. Hi Guys, Real PHP newbie here, and slowly getting to grips with it (I did say slowly, right!). Basically, I've created this register page. It's supposed to ask the user for their username, password, password verificiation, email address and then finally to ask the user to select from a tick list of interests (populated via the DB). Here's my code: <? include('includes/config.php'); $is_error = 0; if ($_POST['task'] == 'singup_do') { $signup_username = $_POST['user_username']; $signup_password = $_POST['user_password']; $signup_pwd_again = $_POST['user_password_again']; $signup_email = $_POST['user_email_address']; $signup_interest = $_POST['signup_interest']; if ($signup_username == ''){ $is_error = 1; $signup_username_msg = 'The username cannot be left blank'; } if ($signup_password == ''){ $is_error = 1; $signup_password_msg = 'Password field cannot be left blank'; } if ($signup_pwd_again == ''){ $is_error = 1; $signup_pwd_again_msg = 'Password again field cannot be left blank'; } if ($signup_email == ''){ $is_error = 1; $signup_email_msg = 'Email cannot be left blank'; } if ($signup_email != '' && !validateEmailAddress($signup_email)) { $is_error = 1; $signup_email_msg = 'Incorrect E-mail address'; } if (!is_array($signup_interest) || count($signup_interest)==0){ $is_error = 1; $signup_interest_msg = 'Please select atleast one interest'; } //EMAIL ADDRESS VALIDATION if ($signup_password!='' && $signup_pwd_again!='' && $signup_password != $signup_pwd_again) { $is_error = 1; $error_msg = 'Passwords don\'t match'; } //USERNAME DUPLICATION VALIDATION if (!$is_error && $signup_username!='' && !checkUsername($signup_username)) { $is_error = 1; $signup_username_msg = 'Username already taken, please enter another'; } if (!$is_error) { $signup_interest_ids = ( is_array($signup_interest) ? implode(',', $signup_interest) : '' ); $users_insert = "INSERT INTO users SET user_id='', user_username = '{$signup_username}' , user_password='{$signup_password}', user_email_address = '{$signup_email}', users_interests='{$signup_interest_ids}', user_active='Y', user_date_added=NOW()"; mysql_query($users_insert); header('Location:login.php?signup=success'); } } ?> <html> <head> <title>Register</title> <link href="css/style.css" rel="stylesheet" type="text/css" /> </head> <body > <div align="center"><BR><BR><BR> <div style="width:50%; "> <form name="frmSignup" action="sign_up.php" method="post"> <input type="hidden" name="task" value="singup_do"> <table width="100%" border="0" cellspacing="4" cellpadding="4" align="center"> <? if ($error_msg!='') {?> <tr><td> </td><td class="tahoma10rednormal"><?=$error_msg?></td></tr> <? }?> <tr><td width="20%" valign="top">Username : </td><td><input name="user_username" type="text" class="textfield" size="35" value="<?=$signup_username?>"/><? if ($signup_username_msg!='') { echo '<BR><span class="tahoma10rednormal">' . $signup_username_msg. '</span>' ; } ?></td></tr> <tr><td valign="top">Password : </td><td><input name="user_password" type="password" class="textfield" size="35" value="<?=$signup_password?>"/><? if ($signup_password_msg!='') { echo '<BR><span class="tahoma10rednormal">' . $signup_password_msg. '</span>' ; } ?></td></tr> <tr><td valign="top">Password (again): </td><td><input name="user_password_again" type="password" class="textfield" size="35" value="<?=$signup_pwd_again?>"/><? if ($signup_pwd_again_msg!='') { echo '<BR><span class="tahoma10rednormal">' . $signup_pwd_again_msg. '</span>' ; } ?></td></tr> <tr><td valign="top">Email address: </td><td><input name="user_email_address" type="text" class="textfield" size="35" value="<?=$signup_email?>"/><? if ($signup_email_msg!='') { echo '<BR><span class="tahoma10rednormal">' . $signup_email_msg. '</span>' ; } ?></td></tr> <tr><td colspan="2" ><b>Interests:</b><? if ($signup_interest_msg!='') { echo ' <span class="tahoma10rednormal">' . $signup_interest_msg. '</span>' ; } ?></td></tr> <tr><td colspan="2"> <? $categories = getCategories(); $categories_count = count($categories); if (is_array($categories)) { $cat_counter=0; ?> <table width="80%" border="0" cellspacing="4" cellpadding="4"> <? foreach($categories as $cats) { if ($cat_counter==0 || ($cat_counter%4) == 0) echo '<tr>'; $chk_selected = ''; if (is_array($signup_interest) && in_array($cats['id'], $signup_interest)) $chk_selected = "CHECKED"; ?> <td><input type="checkbox" name="signup_interest[]" value="<?=$cats['id']?>" <?=$chk_selected?>><?=$cats['text']?></td> <? if ($cat_counter==$categories_count || ($cat_counter%4) == 3) echo '</tr>'; $cat_counter++; } ?> </table> <? } else { echo 'No interest added yet.'; } ?> </tr> <tr> <td> </td> <td><input type="submit" name="submit_btn" value="Sign Up"> <input type="button" name="cancel_btn" value="Cancel" onClick="window.location.href='index.php'"></td> </tr> </table> </div> </div> </body> </html> I'm getting undefined varible errors for: Notice: Undefined variable: error_msg Undefined variable: signup_username_msg Notice: Undefined variable: signup_password_msg Notice: Undefined variable: signup_pwd_again_msg Notice: Undefined variable: signup_email_msg Notice: Undefined variable: signup_interest_msg Notice: Undefined variable: signup_interest Notice: Undefined variable: signup_interest Which as the canny of you will have noticed, is all of them! Hurrah at least I'm consistent! If anyone could help out a n00b I'd be so so grateful. Thanks! Rob I 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'); 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. 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 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! 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> 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. 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. 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); ?> 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";} 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
Hello, I have just upgraded my wampserver and with it MySQL, PHP and PhpMyAdmin versions. And my scripts, which ran normally before, not burst hundreds of undefined variable and undefined index notices. I realize it's "notices", not "errors" but this is quite irritating. I believe it might be due to some upgrade in PHP scripting rules or something but I don't know what. I hope you can help me. The first type of notice is "undefined variable". This function will return the notice if I remove the bold red line, where I define the variable as empty before I use it in the loop. I didn't need to do this before. function statistics($array) { [color=red][b]$list = '';[/b][/color] if(is_array($array)) { foreach($array as $name => $value) { // Rip out the name of the client. $list .= "<li>".$name." - "; // set an integer so we know how many tier2 values we have read. $x = 0; foreach($value as $difference => $sum_total) { // if this is the more than the first tier2 values, use a '+' between the units. $list .= (++$x > 1) ? " + ".$sum_total." ".$difference : $sum_total." ".$difference; } // close the line out. $list .= "</li>"; } } return $list; } To avoid the 10+ like notices on the page I declare them empty before the variable's first occurrence. But this sounds stupid to me. Wasn't this one of PHP's benefits, not to have to declare the variable before using it? I also get about 30+ undefined index notices, e.g. Quote Notice: Undefined index: COMPANY XXX in F:\wamp\www\Project Management\main.php on line 37 Notice: Undefined index: USD in F:\wamp\www\Project Management\main.php on line 37 Notice: Undefined index: USD in F:\wamp\www\Project Management\main.php on line 41 Here are those lines: $income_total = calculate("income"); foreach($income_total as $row) { $clientID = $row['clientID']; $clientname = $row['clientname']; //$client = "<a href=\"index.php?page=Client&do=view&clientID=$clientID\">".$clientname."</a>"; $client = "<a href=\"index.php?page=Project&do=view&sortby=$clientID\">".$clientname."</a>"; $currency = $row['currency']; $client_sum = $row['client_sum']; $year_sum = ''; $year_sum += $client_sum; $income = ''; $income[$client][$currency] += $client_sum; $income_list = statistics($income); $income_all = ''; $income_all[$currency] += $client_sum; } Line 37 is: Quote $income[$client][$currency] = It's the values assigned to $client and to $currency that seem to cause the notice. How do I deal with this? I don't just want to turn error/notice display off, I want to resolve this issue. please help! I am getting undefined index and offset when I duplicated my SEARCH page for when logged in here is my code Code: [Select] <?php include_once("config.php"); include_once("functions.php"); // Check user logged in already: checkLoggedIn("yes"); ?> <!doctype html> <html> <head> <title>Retro and Vintage</title> <meta name="description" content="xxx" /> <meta name="keywords" content="xxx" /> <meta name="Content-Language" content="en-gb" /> <meta name="robots" content="FOLLOW,INDEX" /> <meta name="revisit-after" content="2 days" /> <meta name="copyright" content="jbiddulph.com" /> <meta name="author" content="John Biddulph - Professional web site design and development in the south of england mainly worthing and brighton" /> <meta name="distribution" content="Global" /> <meta name="resource-type" content="document" /> <link rel="stylesheet" type="text/css" href="css/reset.css" /> <link rel="stylesheet" type="text/css" href="css/style.css" title="default" /> <link rel="alternate stylesheet" type="text/css" href="css/style1.css" title="1" /> <link rel="alternate stylesheet" type="text/css" href="css/style2.css" title="2" /> <script type="text/javascript" src="js/stylechanger.js"></script> <script type="text/javascript" src="js/jquery-1.2.1.pack.js"></script> <script type="text/javascript"> function lookup(inputString) { if(inputString.length == 0) { // Hide the suggestion box. $('#suggestions').hide(); } else { $.post("rpc.php", {queryString: ""+inputString+""}, function(data){ if(data.length >0) { $('#suggestions').show(); $('#autoSuggestionsList').html(data); } }); } } // lookup function fill(thisValue) { $('#inputString').val(thisValue); setTimeout("$('#suggestions').hide();", 200); } </script> </head> <body> <?php if($messages) { displayErrors($messages); }?> <header> <div id="title"> <h1>My Pub Space <a href="#" onClick="setActiveStyleSheet('default'); return false;"><img src="images/0.gif" width="15" height="15" border="0" alt="css style" /></a> <a href="#" onClick="setActiveStyleSheet('1'); return false;"><img src="images/1.gif" width="15" height="15" border="0" alt="css style" /></a> <a href="#" onClick="setActiveStyleSheet('2'); return false;"><img src="images/2.gif" width="15" height="15" border="0" alt="css style" /></a> <span> <form method="post" class="textbox" action="search1.php"> City/Town: <input type="text" size="26" class="searchbox" value="" id="inputString" onKeyUp="lookup(this.value);" onBlur="fill();" /> <div class="suggestionsBox" id="suggestions" style="display: none;"> <img src="images/upArrow.png" style="position: relative; top: -36px; left: 105px; z-index:1;" alt="upArrow" /> <div class="suggestionList" id="autoSuggestionsList"> </div> </div> <input type="image" src="images/go.png" height="30" with="30" value="GO" /> </form> </span> </h1> </div> </header> <nav> <ul> <li class="selected"><a href="#">Home</a></li> <li><a href="#">Pubs</a></li> <li><a href="#">Members</a></li> <li><a href="#">Events</a></li> <li><a href="#">Register</a></li> </ul> </nav> <section id="intro"> <header> <h2>Your social guide to going down the pub, online!</h2> </header> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut.</p> <img src="images/pub.jpg" alt="pub" /> </section> <div id="content"> <div id="mainContent"> <section> <article class="blogPost"> <header> <h2>This is the title of a blog post</h2> <p>Posted on <time datetime="2009-06-29T23:31+01:00">June 29th 2009</time> by <a href="#">Mads Kjaer</a> - <a href="#comments">3 comments</a></p> </header> <?php // drop out of PHP mode to display the plain HTML: $Townsearch = $_GET['rsTown']; echo $Townsearch; // Delimiters may be slash, dot, or hyphen list($Town, $County) = split('[,]', $Townsearch); $tableName="pubs"; $targetpage = "search1.php"; $limit = 20; $query = "SELECT COUNT(*) as num FROM $tableName WHERE rsTown LIKE '$Town%'"; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages['num']; $stages = 3; $page = mysql_escape_string($_REQUEST['page']); if( isset($_REQUEST['page']) && ctype_digit($_REQUEST['page']) ) { $page = (int) $_GET['page']; $start = ($page - 1) * $limit; }else{ $start = 0; } // Get page data $query1 = "SELECT * FROM $tableName WHERE rsTown LIKE '$Town%' LIMIT $start, $limit"; $result = mysql_query($query1); // Initial page num setup if ($page == 0){$page = 1;} $prev = $page - 1; $next = $page + 1; $lastpage = ceil($total_pages/$limit); $LastPagem1 = $lastpage - 1; $paginate = ''; if($lastpage > 1) { $paginate .= "<div class='paginate'>"; // Previous if ($page > 1){ $paginate.= "<a href='$targetpage?page=$prev'>previous</a>"; }else{ $paginate.= "<span class='disabled'>previous</span>"; } // Pages if ($lastpage < 7 + ($stages * 2)) // Not enough pages to breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } } elseif($lastpage > 5 + ($stages * 2)) // Enough pages to hide a few? { // Beginning only hide later pages if($page < 1 + ($stages * 2)) { for ($counter = 1; $counter < 4 + ($stages * 2); $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } $paginate.= "..."; $paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>"; $paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>"; } // Middle hide some front and some back elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2)) { $paginate.= "<a href='$targetpage?page=1'>1</a>"; $paginate.= "<a href='$targetpage?page=2'>2</a>"; $paginate.= "..."; for ($counter = $page - $stages; $counter <= $page + $stages; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } $paginate.= "..."; $paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>"; $paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>"; } // End only hide early pages else { $paginate.= "<a href='$targetpage?page=1'>1</a>"; $paginate.= "<a href='$targetpage?page=2'>2</a>"; $paginate.= "..."; for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } } } // Next if ($page < $counter - 1){ $paginate.= "<a href='$targetpage?page=$next'>next</a>"; }else{ $paginate.= "<span class='disabled'>next</span>"; } $paginate.= "</div>"; } echo $total_pages.' Results'; // pagination echo $paginate; ?> <ul> <?php while($row = mysql_fetch_array($result)) { echo '<li>'.$row['rsPubName'].', '.$row['rsTown'].', '.$row['rsCounty'].'</li>'; if ($_SESSION["rsUser"] == "admin") { echo "<a href=\"edit.php?PUBID=".$row['PubID']."\" class=\"small\">edit this pub</a>"; } } ?> </ul> </article> </section> <section id="comments"> <h3>Comments</h3> <article> <header> <a href="#">George Washington</a> on <time datetime="2009-06-29T23:35:20+01:00">June 29th 2009 at 23:35</time> </header> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut.</p> </article> <article> <header> <a href="#">Benjamin Franklin</a> on <time datetime="2009-06-29T23:40:09+01:00">June 29th 2009 at 23:40</time> </header> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut.</p> </article> <article> <header> <a href="#">Barack Obama</a> on <time datetime="2009-06-29T23:59:00+01:00">June 29th 2009 at 23:59</time> </header> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut.</p> </article> </section> <form action="#" method="POST" method="post"> <h3>Post a comment</h3> <p> <label for="name">Name</label> <input name="name" id="name" type="text" required /> </p> <p> <label for="email">E-mail</label> <input name="email" id="email" type="email" required /> </p> <p> <label for="website">Website</label> <input name="website" id="website" type="url" /> </p> <p> <label for="comment">Comment</label> <textarea name="comment" id="comment" required></textarea> </p> <p> <input type="submit" value="Post comment" /> </p> </form> </div> <aside> <section> <header> <h3>Members Login Area</h3> </header> <h4>Welcome <? print($_SESSION["rsUser"]); ?></h4> <a href="logout.php">Logout</a> </section> <section> <header> <h3>Archives</h3> </header> <ul> <li><a href="#">December 2008</a></li> <li><a href="#">January 2009</a></li> <li><a href="#">February 2009</a></li> <li><a href="#">March 2009</a></li> <li><a href="#">April 2009</a></li> <li><a href="#">May 2009</a></li> <li><a href="#">June 2009</a></li> </ul> </section> </aside> </div> <footer> <div> <section id="about"> <header> <h3>About</h3> </header> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco <a href="#">laboris nisi ut aliquip</a> ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> </section> <section id="blogroll"> <header> <h3>Blogroll</h3> </header> <ul> <li><a href="#">NETTUTS+</a></li> <li><a href="#">FreelanceSwitch</a></li> <li><a href="#">In The Woods</a></li> <li><a href="#">Netsetter</a></li> <li><a href="#">PSDTUTS+</a></li> </ul> </section> <section id="popular"> <header> <h3>Popular</h3> </header> <ul> <li><a href="#">This is the title of a blog post</a></li> <li><a href="#">Lorem ipsum dolor sit amet</a></li> <li><a href="#">Consectetur adipisicing elit, sed do eiusmod</a></li> <li><a href="#">Duis aute irure dolor</a></li> <li><a href="#">Excepteur sint occaecat cupidatat</a></li> <li><a href="#">Reprehenderit in voluptate velit</a></li> <li><a href="#">Officia deserunt mollit anim id est laborum</a></li> <li><a href="#">Lorem ipsum dolor sit amet</a></li> </ul> </section> </div> </footer> </body> </html> error lies on these lines Code: [Select] // drop out of PHP mode to display the plain HTML: $Townsearch = $_GET['rsTown']; echo $Townsearch; // Delimiters may be slash, dot, or hyphen list($Town, $County) = split('[,]', $Townsearch); my current code: Code: [Select] $Townsearch = $_REQUEST['rsTown']; list($Town, $County) = split('[,]', $Townsearch); ltrim($County,1); I am getting undefined index and undefined offset, so I tried this: Code: [Select] if $_REQUEST['rsTown'] == ''{ $Townsearch = ''; } else { $Townsearch = $_REQUEST['rsTown']; } but this brought back: Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in D:\retroandvintage.co.uk\wwwroot\main.php on line 6 Can someone please help? thanks |