PHP - Php Getting Min Values Index
<?php
function lowest_int ($c){
}
Hello guys the out of my code should be [0] => -15 [4] => -15 for the first array and [0] => 1 for the second array.
Array ( [0] => 1 [1] => 4 ) Array ( [0] => 0 )
Any ideas what am doing wrong? Thank you so much in advance! Edited June 5, 2019 by PaolaSimilar Tutorials
Table Issue - Multiple Location Values For User Pushes Values Out Of Row Instead Of Wrapping In Cell
Nothing is being returned. Why?
<?php error_reporting(E_ALL); ini_set("display_errors", 1); require("../PHPMailer/class.phpmailer.php"); include 'includes.php'; $mail = new PHPMailer; $subject = $_POST['subject']; $text = $_POST['newsletterBody']; $mail->IsSMTP(); // Set mailer to use SMTP $mail->Host = 'localhost'; // Specify main and backup server $mail->Port = '465'; $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = '**EMAIL_USERNAME**'; // SMTP username $mail->Password = '**EMAIL_PASSWORD**'; $mail->SMTPAuth = true; $mail->SMTPSecure = 'ssl'; // Enable encryption, 'ssl' also accepted $mail->From = '**EMAIL_ADDRESS**'; $mail->FromName = '**EMAIL_NAME'; $email = getEmail("62", $DBH); foreach ($email as $newEmail) { $addEmail = $newEmail->email; $mail->AddAddress($addEmail); $DBH = null; $addEmail = ""; } $mail->AddReplyTo('**EMAIL_REPLY_TO**', '**EMAIL_REPLY_TO_NAME**'); $mail->WordWrap = 50; // Set word wrap to 50 characters $mail->IsHTML(true); // Set email format to HTML $mail->Subject = $subject; $mail->Body = $text; $mail->AltBody = $text; if(!$mail->Send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; exit; } $insertSql = "INSERT INTO newsletter_log (date, title, body) VALUES (?,?,?)"; $insertParams = array(time(), $subject, $text); $newsletterAdd = $DBH->prepare($insertSql); $newsletterAdd->execute($insertParams) echo 'Message has been sent <a href='newsletter.php'>Return back</a>"; ?>This is the include section that you need function getEmail($inId, $DBH) { if (!empty($inId)) { $blogstmt = $DBH->prepare("SELECT email_addr FROM newsletter_emails WHERE id = :userId"); $blogstmt->bindParam(":userId", $inId); $blogstmt->execute(); } else { $blogstmt = $DBH->prepare("SELECT * FROM newsletter_emails"); $blogstmt->execute(); } $postArray = array(); $results = $blogstmt->fetchAll(PDO::FETCH_ASSOC); foreach($results as $row){ $myPost = new nlEmails($row["id"], $row['email'], $DBH); array_push($postArray, $myPost); } return $postArray; $DBH = null; } class nlEmails { public $id; public $email; function __construct($inId=null, $inEmail=null, $DBH) { if(!empty($inId)) { $this->id = $inId; } if(!empty($inEmail)) { $this->email = $inEmail; } } }The database is created with the newsletter_emails "id", "first_name", "last_name", "email_addr". Thanks! I really dont no what the problem is and im new here so i dont no if this is the right place to put this but im trying to make a registration page for my server and when i bring it up it says Undefined index: action in C:\xampp\htdocs\index.php on line 56 and idk what to do >.< this is the line that has the problem if($_POST['action']!="signup") so hopefully u guys could help me :/ Im using xampp btw Hi there, I was wondering if there is a way to display content on only my index.php page? I believe there is a way and I have done it before, but some of my pages use index.php?category etc. Is there a way to show content just on index.php and not on any dynamic pages? Thanks Dear All Members here is my table data.. (4 Columns/1row in mysql table)
id order_no order_date miles How to split(miles) single column into (state, miles) two columns and output like following 5 columns /4rows in mysql using php code.
(5 Columns in mysql table) id order_no order_date state miles 310 001 02-15-2020 MI 108.53 310 001 02-15-2020 Oh 194.57 310 001 02-15-2020 PA 182.22
310 001 02-15-2020 WA 238.57 ------------------my php code -----------
<?php
if(isset($_POST["add"]))
$miles = explode("\r\n", $_POST["miles"]);
$query = $dbh->prepare($sql);
$lastInsertId = $dbh->lastInsertId(); if($query->execute()) {
$sql = "update tis_invoice set flag='1' where order_no=:order_no"; $query->execute();
} ----------------- my form code ------------------
<?php -- Can any one help how to correct my code..present nothing inserted on table
Thank You Edited February 8, 2020 by karthicbabuHi, My company has 240+ locations and as such some users (general managers) cover multiple sites. When I run a query to pull user information, when the user has multiple sites to his or her name, its adds the second / third sites to the next columns, rather than wrapping it inside the same table cell. It also works the opposite way, if a piece of data is missing in the database and is blank, its pull the following columns in. Both cases mess up the table and formatting. I'm extremely new to any kind of programming and maybe this isn't the forum for this question but figured I'd give it a chance since I'm stuck. The HTML/PHP code is below: <table id="datatables-column-search-select-inputs" class="table table-striped" style="width:100%"> <thead> <tr> <th>ID</th> <th>FirstName</th> <th>LastName</th> <th>Username</th> <th>Phone #</th> <th>Location</th> <th>Title</th> <th>Role</th> <th>Actions</th> </tr> </thead> <tbody> <?php //QUERY TO SELECT ALL USERS FROM DATABASE $query = "SELECT * FROM users"; $select_users = mysqli_query($connection,$query);
// SET VARIABLE TO ARRAY FROM QUERY while($row = mysqli_fetch_assoc($select_users)) { $user_id = $row['user_id']; $user_firstname = $row['user_firstname']; $user_lastname = $row['user_lastname']; $username = $row['username']; $user_phone = $row['user_phone']; $user_image = $row['user_image']; $user_title_id = $row['user_title_id']; $user_role_id = $row['user_role_id'];
// POPULATES DATA INTO THE TABLE echo "<tr>"; echo "<td>{$user_id}</td>"; echo "<td>{$user_firstname}</td>"; echo "<td>{$user_lastname}</td>"; echo "<td>{$username}</td>"; echo "<td>{$user_phone}</td>";
//PULL SITE STATUS BASED ON SITE STATUS ID $query = "SELECT * FROM sites WHERE site_manager_id = {$user_id} "; $select_site = mysqli_query($connection, $query); while($row = mysqli_fetch_assoc($select_site)) { $site_name = $row['site_name']; echo "<td>{$site_name}</td>"; } echo "<td>{$user_title_id}</td>"; echo "<td>{$user_role_id}</td>"; echo "<td class='table-action'> <a href='#'><i class='align-middle' data-feather='edit-2'></i></a> <a href='#'><i class='align-middle' data-feather='trash'></i></a> </td>"; //echo "<td><a href='users.php?source=edit_user&p_id={$user_id}'>Edit</a></td>"; echo "</tr>"; } ?>
<tr> <td>ID</td> <td>FirstName</td> <td>LastName</td> <td>Username</td> <td>Phone #</td> <td>Location</td> <td>Title</td> <td>Role</td> <td class="table-action"> <a href="#"><i class="align-middle" data-feather="edit-2"></i></a> <a href="#"><i class="align-middle" data-feather="trash"></i></a> </td> </tr> </tbody> <tfoot> <tr> <th>ID</th> <th>FirstName</th> <th>LastName</th> <th>Username</th> <th>Phone #</th> <th>Location</th> <th>Title</th> <th>Role</th> </tr> </tfoot> </table>
Hi all, I'm a first time poster here and I would really appreciate some guidance with my latest php challenge! I've spent the entire day googling and reading and to be honest I think I'm really over my head and need the assistance of someone experienced to advise the best way to go! I have a multi dimensional array that looks like (see below); the array is created by CodeIgniter's database library (the rows returned from a select query) but I think this is a generic PHP question as opposed to having anything to do with CI because it related to working with arrays. I'm wondering how I might go about searching the array below for the key problem_id and a value equal to a variable which I would provide. Then, when it finds an array with a the matching key and variable, it outputs the other values in that part of the array too. For example, using the sample data below. How would you recommend that I search the array for all the arrays that have the key problem_id and the value 3 and then have it output the value of the key problem_update_date and the value of the key problem_update_text. Then keep searching to find the next occurrence? Thanks in advance, as above, I've been searching really hard for the answer and believe i'm over my head! Output of print_r($updates); CI_DB_mysql_result Object ( [conn_id] => Resource id #30 [result_id] => Resource id #35 [result_array] => Array ( ) [result_object] => Array ( ) [current_row] => 0 [num_rows] => 5 [row_data] => ) Output of print_r($updates->result_array()); Array ( [0] => Array ( [problem_update_id] => 1 [problem_id] => 3 [problem_update_date] => 2010-10-01 [problem_update_text] => Some details about a paricular issue [problem_update_active] => 1 ) [1] => Array ( [problem_update_id] => 4 [problem_id] => 3 [problem_update_date] => 2010-10-01 [problem_update_text] => Another update about the problem with an ID of 3 [problem_update_active] => 1 ) [2] => Array ( [problem_update_id] => 5 [problem_id] => 4 [problem_update_date] => 2010-10-12 [problem_update_text] => An update about the problem with an ID of four [problem_update_active] => 1 ) [3] => Array ( [problem_update_id] => 6 [problem_id] => 4 [problem_update_date] => 2010-10-12 [problem_update_text] => An update about the problem with an ID of 6 [problem_update_active] => 1 ) [4] => Array ( [problem_update_id] => 7 [problem_id] => 3 [problem_update_date] => 2010-10-12 [problem_update_text] => Some new update about the problem with the ID of 3 [problem_update_active] => 1 ) ) Hi all, Just curious why this works: Code: [Select] while (($data = fgetcsv($handle, 1000, ",")) !== FALSE){ $import="INSERT into $prodtblname ($csvheaders1) values('$data[0]','$data[1]','$data[2]','$data[3]','$data[4]','$data[5]','$data[6]')"; } And this does not: $headdata_1 = "'$data[0]','$data[1]','$data[2]','$data[3]','$data[4]','$data[5]','$data[6]'"; while (($data = fgetcsv($handle, 1000, ",")) !== FALSE){ $import="INSERT into $prodtblname ($csvheaders1) values($headdata_1)"; }it puts $data[#'s] in the database fields instead of the actual data that '$data[0]','$data[1]'... relates to. I wrote a script to create the values in $headdata_1 based on the number of headers in $csvheaders1 but can't seem to get it working in the sql statement. Thanks i'm running code on what i only want to be the HOME page, but the current site it built using GET variables with index.php needless to say, the home page is accessed either as domain.com/ or domain.com/index.php - i'm hoping someone can show me how to check for this condition, that it is only index.php without anything further I'm only slightly familiar with $_SERVER['uri'], etc... So i don't know just what to ask. thanks for anyone's help. Glenn I have two files an sample.html which has just a search box some javascript on it to display images when users start typing on this search box. the sample.html works when i entre localhost\index.html now, i have an index.php. when i include("index1.html"); the search box appears but the javascript does not work? why? do i need to relink the following in my sample.html??? <script type="text/javascript" src="autocomplete/lib/jquery.js"></script> <script type='text/javascript' src='jquery.autocomplete.js'></script> <link rel="stylesheet" type="text/css" href="jquery.autocomplete.css" /> fyi i am using wordpress. So I've searched for a few hours already, and decided to give in to asking on a forums. On the site I'm working on, I want the navigation to look like www.website.com/index.php?id=2 instead of www.website.com/contacts.htm Also, the way I did it before, I renamed my main home page as 'main.php' and when you go to the site, index.php will display what's on main.php, but will still show www.website.com/index.php?id=1. I've done it before a few years ago, but I lost the site and forgot how to do it. I'm pretty sure there's a if/else if statement that comes into play, but I don't remember. I hope this all makes sense. Thanks An open question this, and one that may or may not bear fruit. But here we go anyway. index.php is a special case I feel because it is often the default script that is called for a web site. Moreover, I keep mine in the freely available root directory, but the rest of my php is out of the root for security purposes - in a directory called "lib". The app I am working on at the present time requires that a user logs on first. So, the code I have in my index.php is very simple: Code: [Select] <?php /* Require Log In */ require("lib/ezLogin.php"); ?> This at least is what I have presently. So I have a few questions: 1. Is treating index.php as a special case, a reasonable approach would you say? 2. Is the separation of the rest of the non-client php files a real security improvement? 3. When you declare the css path, do you use absolute path names? If so, how might it be done so it will work on local (testing) AND the main server (production) with no code change? 4. includes_path - I assume this is the path to the includes directory. However, I am not sure/happy/comfortable with this just yet. Can more than one path be included in this? (I have Googled around but still unhappy) If so, how so? Does this approach works across platforms? If not, is there a way to make it? Many thanks for any help. S im having problems with the initial loading of a page "Undefined index". i no the problem is due to 2 $vars having no value but i dont no how to get around the problem. its a form that posts to itself then pulls from the database. once you hit submit the problem goes away. i just need to sort the 1st page load out thanks the problem is the 1st 2 lines of the snippet. snippet $ser_type=$_POST['list']; $search = $_POST['search']; if ($search == '' || $search == ' '){ echo "Search Field is Empty - Please Input a Search Query!"; die; } else{ if ($ser_type=="sku"){ $sql = "SELECT * from $tbl_name WHERE sku like '%$search%' or rsku like '%$search%'"; $result = mysql_query($sql); full code <?php include("http://localhost/dsgi/includes/header.html"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Modify DataBase</title> </head> <body> <form method="post" action="main.php"> <table class="tablesrch" width=583 height="101" border="0" align=center> <tr> <td height="32" colspan="2"> <div align="center">Enter Search: <input type=text name='search' size=20 maxlength=255> </div></td> </tr> <tr> <td width="193" align="right">Search By:</td> <td width="380"><label> <input name="list" type="radio" id="SKU" value="sku" checked> SKU <input name="list" type="radio" id="make" value="make"> Make <input type="radio" name="list" id="model" value="model"> Model</label></td> </tr> <td height="28" colspan="2"><div align="center"><input type=submit></div></td></tr> </table> </form> <p align="center"> </p> <table class="table2" align="center"> <tr> <td align="center"> <?php //include("http://localhost/dsgi/includes/config.php"); $INC_DIR = $_SERVER["DOCUMENT_ROOT"]. "/dsgi/includes/"; include($INC_DIR. "config.php"); // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $tbl_name="dsgi_serval"; // Retrieve data from database $ser_type=$_POST['list']; $search = $_POST['search']; if ($search == '' || $search == ' '){ echo "Search Field is Empty - Please Input a Search Query!"; die; } else{ if ($ser_type=="sku"){ $sql = "SELECT * from $tbl_name WHERE sku like '%$search%' or rsku like '%$search%'"; $result = mysql_query($sql); if(mysql_num_rows($result) > 0) { echo "Image is on the server. If not green please inform imaging team"; ?> </td> </tr> </table> <table class="table1" width="800" height="72" align="center"> <tr class="tablehead"> <th width="113" align="center">Recon SKU</th> <th width="66" align="center">Orig SKU</th> <th width="90" align="center">Make</th> <th width="169" align="center">Model</th> <th width="58" align="center">Recovery</th> </span></span></tr> <?php while ($rows=mysql_fetch_array($result)){ // table bg colour $choice = strtoupper($rows['comments']); $findme = 'FAIL'; $findme1 = 'PASS'; $mystring2 = trim($rows['comments']); $pos2 = stripos($mystring2, $findme); $pos1 = stripos($mystring2, $findme1); if ($pos1 !== false){ $bgc = "pass" ; } elseif ($pos2 !== false){ $bgc = "fail" ; }else{ $bgc = "wait" ; } ?> <tr id="tabledata" class="<?php echo "$bgc"; ?>"> <td> <?php echo $rows['sku'] ; ?></td> <td> <?php echo $rows['rsku']; ?></td> <td> <?php echo $rows['make']; ?></td> <td> <?php echo $rows['model']; ?></td> <td> <?php echo $rows['recovery']; ?></td> </tr> <?php } } else { $sql = "SELECT * from dsgi_request WHERE sku = '$search'"; $result = mysql_query($sql); if(mysql_num_rows($result) > 0) { while ($rows=mysql_fetch_array($result)){ ?> Image not found on server. <br> please Inform Engineering Team. <?php } ?> <?php }else{ ?> Image not found on server.<br> please Inform Engineering Team. </table> <table width="350" border="1" align="center" cellpadding="0" cellspacing="1"> <tr> <td><form name="form1" method="post" action="request_ac.php"> <table width="100%" border="1" cellspacing="1" cellpadding="3"> <tr> <th colspan="3" > Image Request </th> </tr> <tr> <td>SKU</td> <td>:</td> <td><input name="sku" type="text" id="sku" size="30" maxlength="6" /></td> </tr> <tr> <td width="97">Make</td> <td width="3">:</td> <td width="222"><input name="make" type="text" id="make" size="30"></td> </tr> <tr> <td>Model</td> <td>:</td> <td><input name="model" type="text" id="model" size="30"></td> </tr> <tr> <td>OS</td> <td>:</td> <td><input name="os" type="text" id="os" value="Which Version? Home, Basic?" size="30" /></td> </tr> <tr> <td>Serial</td> <td>:</td> <td><input name="serial" type="text" id="serial" size="30" /></td> </tr> <tr> <td>Bcn</td> <td>:</td> <td><input name="bcn" type="text" id="bcn" size="30" /></td> </tr> <tr> <td>Cell</td> <td>:</td> <td><label> <select name="personel" id="personel"> <option selected="selected">Laptop Cell</option> <option>Cell A</option> <option>Cell B</option> <option>Cell C</option> <option>Desk Top's</option> </select> </label></td> </tr> <tr> <td>Date</td> <td>:</td> <td><input name="date" type="text" id="date" value="<?php echo date("d, M, Y - h:i:s"); ?>" size="30" readonly="readonly" /></td> </tr> <tr> <td colspan="3" align="center"><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </form> </td> </tr> </table> <?Php } } } else{ $sql = "SELECT * from $tbl_name WHERE $ser_type like '%$search%'"; $result = mysql_query($sql); $srch = strtoupper($search); $sertype = strtoupper($ser_type); // echo "$sertype Search Result's For $srch"; echo "Searched $sertype For $srch"; ?> </td> </tr> </table> <table class="table1" width="800" height="72" align="center"> <tr class="tablehead"> <td>Recon SKU</td> <td>Orig SKU</td> <td>Make</td> <td>Model</td> <td>Recovery</td> </tr> <?php while ($rows=mysql_fetch_array($result)){ // table bg colour $choice = strtoupper($rows['comments']); $findme = 'FAIL'; $findme1 = 'PASS'; $mystring2 = trim($rows['comments']); $pos2 = stripos($mystring2, $findme); $pos1 = stripos($mystring2, $findme1); if ($pos1 !== false){ $bgc = "pass" ; } elseif ($pos2 !== false){ $bgc = "fail" ; }else{ $bgc = "wait" ; } // $bgc = "#EE2C2C" ;red // $bgc = "#FF6600" ; amber ?> <?php $make = strtoupper($rows['make']); ?> <tr id="tabledata" class="<?php echo "$bgc"; ?>"> <td> <?php echo $rows['sku'] ; ?></td> <td> <?php echo $rows['rsku']; ?></td> <td> <?php echo $make; ?></td> <td> <?php echo $rows['model']; ?></td> <td> <?php echo $rows['recovery']; ?></td> </tr> <?php } } } ?> <p> </p> </body> </html> hi guys, I have a form which allows me to update my database with the inputted values, the form works and it updates my database, however I have these error messages all over my webpage Notice: Undefined index: title in C:\xampp\htdocs\CS2410\add_dvd.php on line 12 Notice: Undefined index: category in C:\xampp\htdocs\CS2410\add_dvd.php on line 13 Notice: Undefined index: quantity in C:\xampp\htdocs\CS2410\add_dvd.php on line 14 Notice: Undefined index: price in C:\xampp\htdocs\CS2410\add_dvd.php on line 15 Notice: Undefined index: bar_code in C:\xampp\htdocs\CS2410\add_dvd.php on line 16 the code is below Code: [Select] <?php session_start(); // a security measure, if unautherised users attempt to directly access the page they are redirected to the index page if (!($_SESSION['autherised']== true)) { header("Location:index.php"); } //make a connection to the server or terminate the script if a connection cannot be estabilshed $svc = @mysql_connect("localhost","root") or die ('unable to connect to server'.' '.mysql_error()); //make a connection to the databaes or terminate the script if a connection cannot be estabilshed $dbc = @mysql_select_db("aston_shopdb",$svc) or die ('unable to connect to database'.' '.mysql_error()); $nameofdvd = $_POST['title']; $categoryofdvd = $_POST['category']; $quantity = $_POST['quantity']; $dvdprice = $_POST['price']; $bar_id = $_POST['bar_code']; $sql = "INSERT INTO item SET Title='$nameofdvd', Category='$categoryofdvd', Quantity='$quantity', Price='$dvdprice', Bar_code='$bar_id'"; if (@mysql_query($sql)) { echo('<p>New DVD added</p>'); } else { echo('<p>Error adding new dvd: ' . mysql_error() . '</p>'); } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" type="text/css" href="aston-shop-scheme.css" /> <title>Add a New DVD</title> </head> <form action="<?=$_SERVER['PHP_SELF']?>" method="post"> <p>Enter the new DVD:<br /> Title: <input type="text" name="title" size="20" maxlength="255" /><br /> Category: <input type="text" name="category" size="20" maxlength="255" /><br /> Quantity: <input type="text" name="quantity" size="20" maxlength="255" /><br /> Price: <input type="text" name="price" size="20" maxlength="255" /><br /> Barcode: <input type="text" name="bar_code" size="20" maxlength="255" /><br /> <input type="submit" name="submit" value="SUBMIT" /></p> </form> <table class ="standard" > <tr> <td> <input type ="button" class="input" onClick ="location.href='all_products.php'" value ="View all products"> </td> </tr> <tr> <td> <input type ="button" onclick ="location.href='Logout.php'" value ="Log out"> <td> </tr> </table> </body> </html> please help!!! nick MOD EDIT: code tags added. Problem: Undefined Index on all 'new_picture'. Code of problem: Code: [Select] $new_picture = mysqli_real_escape_string($dbc, trim($_FILES['new_picture']['name'])); $new_picture_type = $_FILES['new_picture']['type']; $new_picture_size = $_FILES['new_picture']['size']; list($new_picture_width, $new_picture_height) = getimagesize($_FILES['new_picture']['tmp_name']); Entire code: Code: [Select] <?php require_once('appvars.php'); include_once('connectvars.php'); $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die ("Cant connect to server " . mysql_error()); if (mysqli_connect_errno()) { echo "Connect failed: " . mysqli_connect_error(); exit(); } if(isset($_POST['upload'])){ $new_picture = mysqli_real_escape_string($dbc, trim($_FILES['new_picture']['name'])); $new_picture_type = $_FILES['new_picture']['type']; $new_picture_size = $_FILES['new_picture']['size']; list($new_picture_width, $new_picture_height) = getimagesize($_FILES['new_picture']['tmp_name']); $error = false; // Validate and move the uploaded picture file, if necessary if (!empty($new_picture)) { if ((($new_picture_type == 'image/gif') || ($new_picture_type == 'image/jpeg') || ($new_picture_type == 'image/pjpeg') || ($new_picture_type == 'image/png')) && ($new_picture_size > 0) && ($new_picture_size <= MM_MAXFILESIZE) && ($new_picture_width <= MM_MAXIMGWIDTH) && ($new_picture_height <= MM_MAXIMGHEIGHT)) { if ($_FILES['file']['error'] == 0) { // Move the file to the target upload folder $target = MM_UPLOADPATH . basename($new_picture); if (move_uploaded_file($_FILES['new_picture']['tmp_name'], $target)) { // The new picture file move was successful, now make sure any old picture is deleted if (!empty($old_picture) && ($old_picture != $new_picture)) { @unlink(MM_UPLOADPATH . $old_picture); } } else { // The new picture file move failed, so delete the temporary file and set the error flag @unlink($_FILES['new_picture']['tmp_name']); $error = true; echo '<p class="error">Sorry, there was a problem uploading your picture.</p>'; } } } else { // The new picture file is not valid, so delete the temporary file and set the error flag @unlink($_FILES['new_picture']['tmp_name']); $error = true; echo '<p class="error">Your picture must be a GIF, JPEG, or PNG image file no greater than ' . (MM_MAXFILESIZE / 1024) . ' KB and ' . MM_MAXIMGWIDTH . 'x' . MM_MAXIMGHEIGHT . ' pixels in size.</p>'; } } // Update the profile data in the database if (!$error) { if (!empty($new_picture)) { $query = "INSERT INTO identification (id, image_url) VALUES ('', $new_picture)"; } mysqli_query($dbc, $query); // Confirm success with the user echo '<p>Image successfully uploaded</p>'; echo '<img src=" '.$new_picture.'" alt="Uploaded Image" />'; } } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <h2>Upload a Photo</h2> <table> <tr> <td> <label for="new_picture">Upload Identification:</label> </td> <td> <input type="file" id="new_picture" name="new_picture" /> </td> </tr> <tr> <td> </td> <td> <input type="submit" value="Upload" name="upload" /> </td> </tr> </table> </form> I don't know how to fix this problem, has anyone got ideas? Hi ive been having an issue with this for a long time and i never found a fix from pure google so i have come to ask other human beings heres my code: Code: [Select] <a href="index.php?page=news">News</a> <?php define ('page', 'page'); switch($_GET[page]) { case "news": include "news.php"; break; case "is-it-for-me": include "for_me.php"; break; } ?> This is what shows up when first entering index.php Quote Notice: Undefined index: page in C:\xampp\htdocs\template1\index.php on line 35 Thanks in advance, Sycohazza Hi all, I'm currently adding something to my website which makes the user input some information before they enter the site, but I'm getting errors saying.. Notice: Undefined index: realname in /home/a5908246/public_html/next.php on line 24 Notice: Undefined index: gamer in /home/a5908246/public_html/next.php on line 48 But with them errors its not showing the actual form where you post the info into. <?php session_start(); include ("includes/config.php"); include ("includes/functions.php"); logincheck(); ini_set ('display_errors', 1); error_reporting (E_ALL); $username = $_SESSION['username']; $get = mysql_query ("SELECT * FROM users WHERE username='$username'") or die (mysql_error()); $got = mysql_fetch_object($get); ?> <html> <head> <title>Please Update..</title> </head> <body> <form action='' method='POST' name='everything'> <?php if ($got->realname == ''){ if ($_POST['realname']){ // Line 24 $input = $_POST['nameinput']; ?> <table width='50%' border='1' class='tableborder2' cellspacing='1' align='center'> <tr> <td class='e_header' align='center'>Error!</td> </tr> <tr> <td class='omg' align='center'>Please Enter your Real Name.</td> </tr> <tr> <td align='center'><input type='text' name='nameinput' class='textinput'></td> </tr> <tr> <td align='center'><input type='button' name='realname' class='button' Value='Update Name!'></td> </tr> </table> <br /> <?php mysql_query ("UPDATE users SET realname='$input' WHERE username='$username'") or die (mysql_error()); }} ?> <?php if ($got->gamertag == ''){ if ($_POST['gamer']){ // Line 48 $inputgamer = $_POST['gamertag']; ?> <table width='50%' border='1' class='tableborder2' cellspacing='1' align='center'> <tr> <td class='e_header' align='center'>Error!</td> </tr> <tr> <td class='omg' align='center'>Please Enter your Gamertag.</td> </tr> <tr> <td align='center'><input type='text' name='gamertag' class='textinput'></td> </tr> <tr> <td align='center'><input type='button' name='gamer' class='button' Value='Update Gamertag!'></td> </tr> </table> <?php mysql_query ("UPDATE users SET gamertag='$inputgamer' WHERE username='$username'") or die (mysql_error()); }} if ($got->realname != '' || $got->gamertag != ''){ // Display, welcome $realname, redirecting you to main site now... (2 seconds waiting) ?> <table width='50%' border='1' class='tableborder2' cellspacing='1' align='center'> <tr> <td class='header' align='center'>Welcome!</td> </tr> <tr> <td class='omg' align='center'>Welcome!</td> </tr> <tr> <td align='center'>You will be redirected to the main site in 2 seconds!<meta http-equiv="refresh" content="2;url=http://******.com/index2.php"></td> </tr> </table> </form> <?php } ?> Thanks for any help/advice given I've done this before and I've never gotten this notice, why am I getting it now? <p> <center><form method = "post" action = ""> <input type = "text" name = "name"> <input type = "password" name = "pass"> <input type = "submit" name = "submit"> </form> </center> </p> '; if($_POST['submit']){ echo"blah"; } Notice: Undefined index: submit Hi there i keep getting an error: Notice: Undefined index: ShipYard in C:\wamp\www\SWB2\test3.php on line 160 Heres the relevant select query: Code: [Select] // COUNT SHIPYARDS $colname_shipyard = 'Empire'; mysql_select_db($database_swb, $swb); $query_shipyard = sprintf("SELECT SUM(ShipYard) FROM planet WHERE PlayerName = %s", GetSQLValueString($colname_shipyard, "text")); $shipyard = mysql_query($query_shipyard, $swb) or die(mysql_error()); $row_shipyard = mysql_fetch_assoc($shipyard); $totalRows_shipyard = mysql_num_rows($shipyard); The error is pointing to: Code: [Select] echo $row_shipyard['ShipYard'];Im a bit of a noob and have tried changing to: Code: [Select] echo $row['ShipYard']; When i do this i get a different error: Notice: Undefined variable: row in C:\wamp\www\SWB2\test3.php on line 159 The row ShipYard is in a table called planet but its not suppose to be indexed or unique. Am I missing something here?? Thanks Hello, I am coding a new game, but rather than having links like /usersonline.php i would like to have game.php?page=usersonline I have never done this before so I'm looking for a quick heads up on the basics if possible. Thanks in advance. Brad Hello i am new to php and i was wondering if someone knew how to do this. I just need a simple index.php file that lists the files and folders in a directory but i need it to look exactly like this (With Bullets): Thank You In Advance (I also need it to open the folder directory if a folder is clicked on and button for Parent Directory) |