PHP - Showing When Shouldnt
Hi all,
I have a simple upload form which is just to upload an image to a folder, this all works fine apart from one bit, once the image has been submitted then a box appears thanking the user for their upload and a close box link, then the original form also appears! I dont want this to appear once I file has been uploaded. I thought my below code would achieve that with an if statement but it is not working: <?php session_start(); $user_id = $_SESSION['user_id']; if (file_exists($user_id.'.'.$extension)) { define ("MAX_SIZE","100"); function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $errors=0; if(isset($_POST['Submit'])) { $image=$_FILES['image']['name']; if ($image) { $filename = stripslashes($_FILES['image']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { echo '<h1>Unknown extension!</h1>'; $errors=1; } else { $size=filesize($_FILES['image']['tmp_name']); if ($size > MAX_SIZE*1024) { echo '<h1>You have exceeded the size limit!</h1>'; $errors=1; } $image_name=$user_id.'.'.$extension; $newname="romimages/".$image_name; $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo '<h1>Copy unsuccessfull!</h1>'; $errors=1; }}}} if(isset($_POST['Submit']) && !$errors) { ?> <link href="../Styles/form_dark.css" rel="stylesheet" type="text/css" /> <form class="dark" action="" method="post" > <ol> <li> <fieldset> <legend>Rom Logo Uploaded!</legend> <p> </p> <ol> <li> <label for="">Your image has been uploaded, you can now close this window</label> </li> </ol> </fieldset> </li> </ol> <br> <input type="submit" value="Close" name="submit" onClick="return parent.parent.GB_hide()" > </p> </form> <?php } } else { ?> <link href="../Styles/form_dark.css" rel="stylesheet" type="text/css" /> <form method="post" enctype="multipart/form-data" action="" class="dark"> <ol> <li> <input type="file" name="image" width="45px"> </li><br> <br> <li> <input name="Submit" type="submit" value="Upload image"> </form> <?php } ?> thanks Similar TutorialsI am probably making a dumb mistake...but heres the code... $gif = '.gif'; $jpg = '.jpg'; $jpeg = '.jpeg'; $png = '.png'; $jpeg1 = 'jpeg'; $gif1 = 'gif'; $jpg1 = 'jpg'; $png1 = 'png'; $max_file_size = '1048576'; $new_avatar = $_FILES['uploaded_avatar']['name']; $avatar_ext = end(explode('.', $new_avatar)); if (isset($_POST['change_submit1'])) { if ($_SESSION['logged_in'] != '1') { echo 'You need to be logged in!'; } elseif ($_POST['change_box1'] != 'CHANGE') { echo 'You must fill in the "CHANGE" box!'; } elseif (($uploaded_a_file == '1') && ($avatar_ext != $jpg1) && ($avatar_ext != $png1) && ($avatar_ext != $gif1) && ($avatar_ext != $jpeg1)) { echo 'File format not supported!'; } elseif ($uploaded_a_file != '1') { echo 'No file selected!'; } elseif ($_FILES["uploaded_avatar"]["size"] > $max_file_size) { echo 'File is too big!'; } } this is the code that should be echoing my avatar upload errors. Ive checked all the if statements ive changed the order around. still nothing. all of them work other than file format not supported. I can get this one to work...but at the cost of no file selected not working...help! Hey all. I have a simple code for verifying some data. I have two echos from if statements. The first is if the text input is empty echo: HELLO. The second is if text input data is not found in database echo: NOPE. Now in the following code the second one works fine. But the problem is if I leave the field empty BOTH echos show. So if I leave the input empty instead of saying "HELLO" it says, "HELLONOPE". Yet the second one works fine and display only "NOPE" The other thing is if I switch the two echos to die instead, they work fine. Code: [Select] if (isset($_POST['submit'])) { // if form has been submitted // makes sure they filled it in if(!$_POST['id']) { echo "HELLO"; } // checks it against the database $check = mysql_query("SELECT * FROM emp WHERE id = '".$_POST['id']."'")or die(mysql_error()); //Gives error if user dosen't exist $check2 = mysql_num_rows($check); if ($check2 == 0) { echo "NOPE"; } else { //if login good then redirect them to the members area $id = $_POST['id']; header("Location: somepage.php?id=$id"); } } else { // they are not logged in } <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <input type="text" name="id" maxlength="40"> <input type="submit" name="submit" value="Login"> </form> What am I doing wrong? I am pretty new to PHP and am trying to create a simple (so I assumed) page to takes data from one html page(works fine) and updates a MYSQL Database. I am getting no error message, but the connect string down to the end of the body section is showing up as plain text in my browser window. I do not know how to correct this. I have tried using two different types of connect strings and have verified my names from the HTML page are the same as listed within the php page. Suggestions on what I need to look for to correct would be great. I have looked online, but so far all I am getting is how to connect, or how to create a comment, so I thought I would try here. Thank you for any assistance I may get!! - Amy - Code: [Select] <body><font color="006600"> <div style="background-color:#f9f9dd;"> <fieldset> <h1>Asset Entry Results</h1> <?php // create short variable names $tag=$_POST['tag']; $serial=$_POST['serial']; $category=$_POST['category']; $status=$_POST['status']; $branch=$_POST['branch']; $comments=$_POST['comments']; if (!$tag || !$serial || !$category || !$status || !$branch) { echo "You have not entered all the required details.<br />" ."Please go back and try again."; exit; } if (!get_magic_quotes_gpc()) { $tag = addslashes($tag); $serial = addslashes($serial); $category = addslashes($category); $status = addslashes($status); $branch = addslashes($branch); $comments = addslashes($comments); } //@ $db = new mysqli('localhost', 'id', 'pw', 'inventory'); $db = DBI->connect("dbi:mysql:inventory:localhost","id","pw") or die("couldnt connect to database"); $query = "insert into assets values ('".$serial."', '".$tag."', '".$branch."', '".$status."', '".$category."', '".$comments."')"; $result = $db->query($query); if ($result) { echo $db->affected_rows." asset inserted into Inventory."; } else { echo "An error has occurred. The item was not added."; } $db->close(); ?> </fieldset> </div> </body> I decided to redo the individual roster page I have on my site and came up with this. <?php if(isset($_GET['username']) && $_GET['username'] != '') { $username = $_GET['username']; $query = "SELECT bio.username AS username, bio.charactername AS charactername, bio.id AS id, bio.style_id AS style FROM `efed_bio` AS bio ON bio.id = ebw.bio_id WHERE bio.username = '$username'"; if(!$result = mysql_query($query)) while ($row = mysql_fetch_assoc($result)) { $fieldarray=array('id','username','charactername','style'); foreach ($fieldarray as $fieldlabel) { if (isset($row[$fieldlabel])) { $$fieldlabel=$row[$fieldlabel]; $$fieldlabel=cleanquerydata($$fieldlabel); } } } } ?> <h1><?php echo $charactername; ?>'s Biography</h1> <?php echo getBioMenu($style,$username); ?> <? //If the GET page variable is biography, display the biography page if ($page == 'biography') { echo getBiopgrahy($style,$id); } //Or if the GET page variable is gallery, display the gallery page elseif ($page == 'gallery') { echo getGallery($style,$id); } //If the GET page variable is news, display the news page elseif ($page == 'news') { echo getNews($$id); } //If the GET page variable is segments, display the segments page elseif ($page == 'segments') { echo getBioSegments($id,S); } //If the GET page variable is matches, display the matches page elseif ($page == 'matches') { echo getBioSegments($id,M); } elseif ($page == 'chronology') { echo getChronology($id); } //Otherwise display the bio else { echo getBio($style,$id); } ?> The list of characters are listed he http://kansasoutlawwrestling.com/roster An example of someone's individual roster page is located he http://kansasoutlawwrestling.com/bio?username=oriel I have a really strange query for you all to figure out why I'm not coming up with the right SELECT statement. I've echoed it and I'll show you what I get for a result from the echo as well. Table- Users Fields- id,creator_id,username,password,firstname,lastname,email,status_id,isadmin,datecreated $query = "SELECT CONCAT_WS(' ', firstname, lastname) AS name, CONCAT_WS(' ', firstname, lastname) AS handler, DATE_FORMAT(datecreated, '%M %d, %Y') AS datecreated, id, username, email FROM handlers WHERE handlers.id = handlers.creator_id"; produced this result... SELECT CONCAT_WS(' ', firstname, lastname) AS name, CONCAT_WS(' ', firstname, lastname) AS handler, DATE_FORMAT(datecreated, '%M %d, %Y') AS datecreated, id, username, email FROM handlers WHERE handlers.id = handlers.creator_id php data table code: <?php $query = "SELECT CONCAT_WS(' ', firstname, lastname) AS name, CONCAT_WS(' ', firstname, lastname) AS handler, DATE_FORMAT(datecreated, '%M %d, %Y') AS datecreated, id, username, email FROM handlers WHERE handlers.id = handlers.creator_id"; $result = mysqli_query ( $dbc, $query ); // Run The Query $rows = mysqli_num_rows($result); echo $query; <?php if ($rows > 0) { ?> <table cellspacing="0" class="listTable" id="handlersPageList"> <!-- Thead --> <thead> <tr> <th class="first"><div></div></th> <th><a href="#" title="Handler Name">Handler Name</a></th> <th><a href="#" title="Handler Username">Handler Username</a></th> <th><a href="#" title="Handler Emal">Handler Email</a></th> <th><a href="#" title="Creator">Creator</a></th> <th class="last"><a href="#" title="Date Created">Date Created</a></th> </tr> </thead> while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) { echo ' <tr> <td><input type=checkbox class=checkbox value="' . $row['id'] . '" /></td> <td>' . $row['handler'] . '</td> <td>' . $row['username'] . '</td> <td><a href="mailto:' . $row['email'] . '>' . $row['email'] . '</a></td> <td>' . $row['name'] . '</td> <td class=last>' . $row['datecreated'] . '</td> </tr>'; } ?> I just decided to take out the parts of the page that would be needed to answer this problem instead of the whole file. This is a little confusing okay lets say the first user is the Administrator with an id of 1 obviously has a first name and last name and username and email and the date he registered is his datecreated and his creator_id is going to be preset because he created it himself so its going to be 1. The 1st row in the database displays fine however I have 4 other rows that for some reason aren't displaying. And don't know why. For handlers 2-4 they all have their own first and last names and usernames and everything else however when it comes to the creator_id those 3 have a creator_id of 1 representing that the Administrator created it so in the data table instead of it showing the value of 1 for the creator_id I just want it to get the CONCCAT version of the first and last name of the Administrator. In the past I have not done a very good job of explaining things so I hope this is more than clarified my intention with my code and what it should do and what it is doing wrong right now. If you have any other questions please ask. I am wanting to echo one of these 4 statements depending on the 'status' value. Currently it is showing the status value on the 2nd line but not the statement below.. Code: [Select] <li> <strong>Status: </strong><?php more_fields('status') ?> <?php if (more_fields('status')=="Red") echo "Your account is currently undergoing judgement"; elseif (more_fields('status')=="Green") echo "Your account is currently Live"; elseif (more_fields('status')=="Yellow") echo "Your account is currently undergoing site visits"; elseif (more_fields('status')=="Blue") echo "Your account is currently undergoing insolvency/liquidation";?> </li> any help appreciated. Thanks, Jake Hello all, I am trying to get a simple members.php page to show some HTML but I cannot figure out why it will not display.. Code: [Select] <?php mysql_connect("myserver", "myname", "mypass") or die(mysql_error()); mysql_select_db("mydb") or die(mysql_error()); if(isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM Users WHERE name = '$name'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if ($password != $info['password']) { header("Location: login.php"); } else { ?> <html> <body> <h1>WHY</h1> </body> </html> <?php } } } else { header("Location: login.php"); } ?> I was googling and read somewhere that it might be a session bug after the initial '<?php tag'? Any help would be greatly appreciated Tokae hello team, can you please look at this code snippet and tell me why it is showing the following data this way? <?php # jeff Exp $ include("app.php"); $page->set("title", "Business & Commerical"); $what = $page->getvar("what"); $type = $page->getvar("type"); $dt = new xDataTable('width="500"'); $form = new Form(); if($what == "submit") $html->set("readonly", true); $dt->header($_types{$type} . " Quote"); $form->get_contact_form(true); When I run it, it shows like this: set("title", "Business & Commerical"); $what = $page->getvar("what"); $type = $page->getvar("type"); $dt = new xDataTable('width="500"'); $form = new Form(); if($what == "submit") $html->set("readonly", true); $dt->header($_types{$type} . " Quote"); $form->get_contact_form(true); switch ($type) { case "comp": $dt->left("Business Type:"); $dt->cell($html->select("business_type", $_business_type, 1, "", $page->getvar("business_type"), "(select)")); $dt->left("Federal Tax ID:"); $dt->cell($html->textfield("tax_id", $page->getvar("tax_id"), 12)); $dt->left("If Individual, Owner SSN#:"); $dt->cell($html->textfield("ssn", $page->getvar("ssn"), 12)); $dt->cell("Spouse SSN#:"); $dt->cell($html->textfield("spouse_ssn", $page->getvar("spouse_ssn"), 12)); just a small sample. What am I doing wrong? Thanks alot in advance Hi People. Here is a form that is supposed to read from my database. My primary key is called "index" and I have about 300 records in the database. I wanted to be able to view the records but when I load this page the "php" part is empty. I simply get given a blank form. I know it is connecting to the DB OK because I changed one letter in the password and then got a "can't connect to the database error" just to test it out. Code: [Select] <?php $host = 'localhost'; $usr = "the_db_user"; $password = 'not_shared_on_forum'; $db_name = 'stranded'; function cr($string){ $clean_string = str_replace("rn","<BR>",$string); return $clean_string; } //$id = 11; if (!isset($id)) $id = $_GET['id']; mysql_connect ("$host","$usr","$password") or die ('Error During Connect:<br>'.mysql_error()); mysql_select_db ("$db_name") or die ('Error Selecting DB:<br>'.mysql_error()); $read_query = "select * from HelperFormData where index = '$id'"; $results = mysql_query($read_query); $rs = mysql_fetch_array($results); ?> <!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>Untitled Document</title> <style type="text/css"> <!-- body,td,th { font-size: 12px; } --> </style></head> <body> Surname: <? echo $rs["surname"]; ?> <table width="500" border="1" bordercolor = "#2c2cf6" textcolor = "#2c2cf6"cellspacing="1" cellpadding="2"> <tr> <td colspan="5">Record number: <? echo $rs["index"]; ?></td> </tr> <tr> <td width="120" bgcolor = #E6F8EB>Surname</td> <td width="120" bgcolor = #E6F8EB>First Name</td> <td width="120" bgcolor = #E6F8EB>phone1</td> <td width="120" bgcolor = #E6F8EB>phone2</td> <td width="120" bgcolor = #E6F8EB>Location</td> </tr> <tr> <td bgcolor = #E6F8EB textcolor = #AC1636><strong><? echo $rs["surname"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["firstname"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["phone1"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["phone2"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["location"]; ?></strong></td> </tr> <tr> <td bgcolor = #dbeff8>Qualifications</td> <td bgcolor = #dbeff8>Expertise</td> <td bgcolor = #dbeff8>Assistance</td> <td bgcolor = #dbeff8>Languages</td> <td bgcolor = #dbeff8>E-Mail</td> </tr> <tr> <td bgcolor = #dbeff8><strong><? echo $rs["qualifications"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["expertise"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["assistance"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["languages"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["e_mail"]; ?></strong></td> </tr> <tr> <td bgcolor = #E6F8EB>Consent</td> <td bgcolor = #E6F8EB>Published</td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> </tr> <tr> <td bgcolor = #E6F8EB><strong><? echo $rs["consent"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["radio_callsign"]; ?></strong></td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> </tr> <tr> <td colspan="5"><p>Comments:<br /> <strong><? echo $rs["comments"]; ?></strong></td> </tr> </table> </body> </html> </html> I am working on a code that I started along time ago but having problem showing the end time, could somebody please have a look at my code to see what I am missing. Thanks Code: [Select] $getEvent_sql = "SELECT id, event_title, event_shortdesc, date_format(event_start, '%l:%i %p') as fmt_date, date_format(event_end, '%l:%i %p') as fmt_enddate FROM calendar_events WHERE month(event_start) = '".$m."' AND dayofmonth(event_start) = '".$d."' AND year(event_start)= '".$y."' ORDER BY event_start"; $getEvent_res = mysql_query($getEvent_sql, $mysql) or die(mysql_error($mysql)); if (mysql_num_rows($getEvent_res) > 0){ $event_txt = "<ul>"; while($ev = @mysql_fetch_array($getEvent_res)){ $evid = $ev["id"]; $event_title = stripslashes($ev["event_title"]); $event_shortdesc = stripslashes($ev["event_shortdesc"]); $fmt_date = $ev["fmt_date"]; $fmt_enddate = $ev["fmt_enddate"]; $event_txt .= "<li><a href=editevent.php?id=$evid>$editevent</a><a href=deleteevent.php?id=$evid>$deleteevent</a><strong>".$fmt_date."</strong>: ".$event_title."<br/>".$event_shortdesc."</li>"; } $event_txt .="</ul>"; mysql_free_result($getEvent_res); } else { $event_txt = ""; } mysql_close($mysql); if ($event_txt != ""){ echo "<p><strong>Today's Events:</strong></p> $event_txt <hr/>"; } The following code should output 1743425391, but it does not show anything <?php $xml_feed_url = 'http://api.eve-online.com/eve/CharacterID.xml.aspx?names=TX1'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $xml_feed_url); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $xml = curl_exec($ch); curl_close($ch); $xmlr = new SimpleXMLElement($xml); $charid = $xmlr->result->characterID; echo $charid; ?> The xml is: Code: [Select] <eveapi version="2"> <currentTime>2011-02-01 05:22:38</currentTime> − <result> − <rowset name="characters" key="characterID" columns="name,characterID"> <row name="TX1" characterID="1743425391"/> </rowset> </result> <cachedUntil>2011-03-01 05:22:38</cachedUntil> </eveapi> Any ideas where I went wrong? Hello: I have this bit of code in the works (which does not work): Code: [Select] <?php if ( $mySubHeader; != "" ) { echo " <h2> <?php echo $mySubHeader; ?> </h2> "; } What I am trying to do is to show the H2 tag only if it has a value from the database. Otherwise, I do not want to show it. What is the correct way to do this? Thanks. Hey all, Been coding another script for my website which allows me to update a users Rank, allthough, when I try and view the page its giving me a White Blank Page. I carn't accually see whats wrong in my Script... <?php session_start(); include ("../includes/config.php"); include ("../includes/function.php"); logincheck(); ini_set ('display_errors', 1); error_reporting (E_ALL); $username = $_SESSION['username']; // Owner Script - Change Users Rank $userlevel = mysql_query ("SELECT * FROM users WHERE username = '$username' LIMIT 1") or die ("Error Finding Right Users " . mysql_error()); $levelright = mysql_fetch_object($userlevel); // If userlevel isn't 5, move them on... if ($levelright->userlevel == "1" || $levelright->userlevel == "2" || $levelright->userlevel == "3" || $levelright->userlevel == "4"){ header ("Location: 404.php"); die(); } // Start Change Rank... if (strip_tags($_POST['changerank'])){ $name = $_POST['name']; $userchange = $_POST['userchange']; $real = mysql_query ("SELECT * FROM users WHERE username = '$userchange' LIMIT 1"); $number = mysql_num_rows($real); if ($number != "1"){ echo ("$userchange, is NOT registered! - Simple Words : No Such User!"); } if ($name == 1){ $reprand = rand(100, 50000); mysql_query ("UPDATE users SET rank = 'Learner Driver (1)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 1 if ($name == 2){ $reprand = rand(50000, 200000); mysql_query ("UPDATE users SET rank = 'Passed Driver (2)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 2 if ($name == 3){ $reprand = rand(200000, 500000); mysql_query ("UPDATE users SET rank = 'New Driver (3)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 3 if ($name == 4){ $reprand = rand(500000, 2500000); mysql_query ("UPDATE users SET rank = 'Speeding Driver (4)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 4 if ($name == 5){ $reprand = rand(2500000, 7000000); mysql_query ("UPDATE users SET rank = 'Skilled Driver (5)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 5 if ($name == 6){ $reprand = rand(7000000, 20000000); mysql_query ("UPDATE users SET rank = 'Maniac Driver (6)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 6 if ($name == 7){ $reprand = rand(20000000, 45000000); mysql_query ("UPDATE users SET rank = 'Wanted Racer (7)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 7 if ($name == 8){ $reprand = rand(45000000, 90000000); mysql_query ("UPDATE users SET rank = 'Pro Driver (8)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 8 if ($name == 9){ $reprand = rand(90000000, 115000000); mysql_query ("UPDATE users SET rank = 'Supreme Racer (9)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 9 if ($name == 10){ $reprand = rand(115000000, 150000000); mysql_query ("UPDATE users SET rank = 'Super Supreme Racer (10)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 10 if ($name == 11){ $reprand = rand(150000000, 210000000); mysql_query ("UPDATE users SET rank = 'Show Off Driver (11)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 11 if ($name == 12){ $reprand = rand(210000000, 280000000); mysql_query ("UPDATE users SET rank = 'Extreme Show Off Driver (12)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 12 if ($name == 13){ $reprand = rand(280000000, 350000000); mysql_query ("UPDATE users SET rank = 'Trained Driver (13)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 13 if ($name == 14){ $reprand = rand(350000000, 430000000); mysql_query ("UPDATE users SET rank = 'Super Trained Driver (14)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 13 if ($name == 15){ $reprand = rand(430000000, 520000000); mysql_query ("UPDATE users SET rank = 'Legendry Racer (15)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 15 if ($name == 16){ $reprand = rand(520000000, 600000000); mysql_query ("UPDATE users SET rank = 'Most Legendry Racer (16)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 16 if ($name == 17){ $reprand = rand(600000000, 1000000000); mysql_query ("UPDATE users SET rank = 'Official SD Legend (17)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 17 if ($name == 18){ $reprand = rand(1000000000, 1000000010); mysql_query ("UPDATE users SET rank = 'Hidden Rank! (18)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 18 echo ("Successfully updated $userchange Rank!"); mysql_query("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `date` , `read` , `saved` , `event_id` ) VALUES ( '', '$userchange', 'System', 'Your Rank has now been changed!', '$date', '0', '0', '0')") or die ("Error updating there inbox!" . mysql_error()); } // Rank Change if (strip_tags($_POST['selectname'])){ $writenname = $_POST['nameinput']; $rankinput = $_POST['rankinput']; $repinput = $_POST['repinput']; $findme = mysql_query ("SELECT * FROM users WHERE username = '$writenname' LIMIT 1") or die ("Error Searching Names " . mysql_error()); $found = mysql_num_rows($findme); if ($found != "1"){ echo ("$writenname, isn't Registered! - Simple Terms : No Such User"); }else{ mysql_query ("UPDATE users SET rank = '$rankinput' AND rep = '$repinput' WHERE username= '$writenname'") or die ("Error Updating Rank + Rep " . mysql_error()); echo ("$writenname Rank has now been changed!"); mysql_query("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `date` , `read` , `saved` , `event_id` ) VALUES ( '', '$writenname', 'System', 'Your Rank has now been changed!', '$date', '0', '0', '0')") or die ("Error updating there inbox!" . mysql_error()); } // Found? } // Post selectname ?> <html> <head> <title>Change Users Rank</title> </head> <body class='body'> <form action='' method='POST' name='Change Rank'> <table width='40%' border='1' cellpadding='0' cellspacing='0' class='table' align='center'> <tr> <td class='header' align='center' colspan='2'>Change Users Rank?</td> </tr> <tr> <td class='omg' align='center'>This will change the users Current Rank!</td> </tr> <tr> <td align='right'>Username:</td><td><input type='text' name='userchange' class='input'></td> </tr> <tr> <td><select name='name' size='1' class='dropbox'> <option value="1">Learner Driver (1)</option> <option value="2">Passed Driver (2)</option> <option value="3">New Driver (3)</option> <option value="4">Speeding Driver (4)</option> <option value="5">Skilled Driver (5)</option> <option value="6">Maniac Driver (6)</option> <option value="7">Wanted Racer (7)</option> <option value="8">Pro Driver (8)</option> <option value="9">Supreme Racer (9)</option> <option value="10">Super Supreme Racer (10)</option> <option value="11">Show Off Driver (11)</option> <option value="12">Extreme Show Off Driver (12)</option> <option value="13">Trained Driver (13)</option> <option value="14">Super Trained Driver (14)</option> <option value="15">Legendry Racer (15)</option> <option value="16">Most Legendry Racer (16)</option> <option value="17">Official SD Legend (17)</option> <option value="18">Hidden Rank! (18)</option></td> </tr> <tr> <td class='omg' align='center' colspan='2'><input type='submit' name='changerank' class='button'></td> </tr> </table> <br /> <table width='40%' border='1' cellpadding='0' cellspacing='0' class='table' align='center'> <tr> <td class='header' align='center' colspan='2'>Change Rank?</td> </tr> <tr> <td class='omg' align='center'>This will change the <strong>posted</strong> users Rank and Rep!</td> </tr> <tr> <td align='right'>Username:</td><td><input type='text' name='nameinput' class='input'></td> </tr> <tr> <td align='right'>Rank:</td><td><input type='text' name='rankinput' class='input'></td> </tr> <tr> <td align='right'>Rep:</td><td><input type='text' name='repinput' class='input'></td> </tr> <tr> <td align='center' colspan='2'><input type='submit' name='selectname' class='button'></td> </tr> </table> </form> </body> </html> Anyone able to see where I'm going wrong? Thanks i have the following code: <?php session_start(); include "connect.php"; $queryFinished = mysql_query("SELECT * FROM `finished` ORDER BY auctionID DESC LIMIT 10;") or die(mysql_error()); $queryAdmin = mysql_query("SELECT maxClosed FROM `admin`;") or die(mysql_error()); //echo $queryAuctionID." = Auction ID<br />"; $username = mysql_fetch_assoc($queryFinished); $queryShip = mysql_query("SELECT * FROM ships WHERE typeName='$username[itemName]';") or die(mysql_error()); $getShip = mysql_fetch_assoc($queryShip); $shipID = $getShip[typeID]; echo "<img src='http://image.eveonline.com/Character/".$username[charid]."_32.jpg'> <span class='eveyellow'>".$username[username]."</span> has won a <img src='/images/types/shiptypes_png/32_32/".$shipID.".png'/> ".$username[itemName]." with ticket number #".$username[ticketNumber]."<br />"; ?> it basically lists the most recent auctions that have won, but even though i set the query to LIMIT by 10 it still only shows the 1? is something above sticking out to anyone? i know it looks messy but im still learning. Hi Friends, I have form in that i am sending some values using POST method. But i cant able to get values using $_POST['var'] or $_REQEUST['var'] Data is not coming in IE6, But it is coming in firefox and other browsers even in IE8. What may be problem? any settings i have to make for IE6. ? Any suggestions Hi: Can someone tell me why the code below is not displaying any data. It's suppose to write the calendar dates and event info, but nothing is showing up. No errors, either .. ?? Code: [Select] <td width="50" <?=hiLightEvt($month,$i,$year);?>> <?php if(isset($_GET['full'])){ $result = mysql_query($sql); $row = mysql_fetch_assoc($result); echo $row['calName']; }else{ $sql="select calID, calDate, calName, calDesc from calTbl where calDate = '" . $month . '/' . $day . '/' . $year . "'"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ echo $row['calName']; ?> <a href="<?=$_SERVER['PHP_SELF'] . '?month='. $month . '&day=' . $i . '&year=' . $year;?>&v=1"><?=$row['calDate'];?></a> <?php } } ?> </td> Help, please .... I am working on building a code that will check the results returned from and xml pull to see if they match the database and print back pass or fail on the screen, it works for the first result but then fails to display anything else. any help on where I went wrong would be helpful. Code: [Select] <?php function pass($name, $level) { $sql1 = "SELECT * FROM `reqskills` WHERE `level` > 0 and `name` = '$name'"; $result1 = mysql_query($sql1); while($row1 = mysql_fetch_array($result1)) { if($level >= $row1['level']) { echo "Pass"; } Else { echo "Fail"; } } } $API = "address removed"; $xml = simplexml_load_file($API); $sql = "SELECT * FROM `reqskills` WHERE `level` > 0"; $result = mysql_query($sql); echo "<table width=100%"; echo "<tr><td>Skill</td><td>Level</td><td>Pass</td></tr>"; while($row = mysql_fetch_array($result)) { ?> <tr> <td><?php echo $row['name'] ?></td> <td><?php echo $row['level'] ?></td> <td><?php foreach ($xml->result->rowset[0] as $value) { $typeID = $value['typeID']; $sql = "select * from `invTypes` WHERE `typeID` = $typeID"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) { echo pass($row['typeName'],$value['level']); }} echo "</td></tr>"; } echo"</table>"; ?> I am developing hospital managment system using php. I have IPD data sheet. When I select patient it is not showing pt data as it should do. Please let me know if any coding needs to place here. I am new to PHP. Below is my code <?php //create array to temporarily grab variables $input_arr = array(); //grabs the $_POST variables and adds slashes foreach ($_POST as $key => $input_arr) { $_POST[$key] = addslashes($input_arr); } ?> <?php session_start(); $db = mysqli_connect('localhost', 'root', '', 'ratanba_new'); // initialize variables $reg_no = ""; $name = ""; $father_name = ""; $sir_name = ""; $sex = ""; $age = ""; $full_name = ""; $dob = ""; $update = false; $patient_master_id = ""; $ipd_id = 0; $IPNo = ""; $fees = ""; $opd_date = ""; $pulse = ""; $bps = ""; $bpd = ""; $weight = ""; $spo2 = ""; if (isset($_POST['admit'])) { function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); $data = ucwords($data); return $data; } $patient_master_id = $_POST['patient_master_id']; $IPNo = $_POST['IPNo']; $RegNo = $_POST['reg_no']; $Name = $_POST['Name']; $Age = $_POST['Age']; $Sex = $_POST['sex']; $Contact1 = $_POST['Contact1']; $Relation1 = $_POST['Relation1']; $Mobile1 = $_POST['Mobile1']; $Contact2 = $_POST['Contact2']; $Relation2 = $_POST['Relation2']; $Mobile2 = $_POST['Mobile2']; $Adate = $_POST['Adate']; $Award = $_POST['Award']; mysqli_query($db, "INSERT INTO IPD (IPNo, RegNo, Name, Age, Sex, Contact1, Relation1, Mobile1, Contact2, Relation2, Mobile2, Adate, Award) VALUES ('$IPNo', '$RegNo', '$Name', '$Age', '$Sex', '$Contact1', '$Relation1', '$Mobile1', '$Contact2', '$Relation2', '$Mobile2', NOW(), '$Award')"); $_SESSION['message'] = "New Admission Successfull !"; header('location: ../ipd.php'); } if (isset($_POST['Discharge'])) { $ipd_id = $_POST['ipd_id']; $Outcome = $_POST['Outcome']; mysqli_query($db, "UPDATE ipd SET Outcome='$Outcome', Ddate=NOW() WHERE ipd_id=$ipd_id"); $_SESSION['message'] = "Patient discharged Successfull !"; header('location: ../ipd.php'); } if (isset($_POST['final_discharge'])) { $ipd_id = $_POST['ipd_id']; $History = $_POST['History']; $Examination = $_POST['Examination']; $Investigation = $_POST['Investigation']; $Advise = $_POST['Advise']; $Diagnosis = $_POST['Diagnosis']; $Treatment = $_POST['Treatment']; $Operation = $_POST['Operation']; $OTnote = $_POST['OTnote']; $Condition1 = $_POST['Condition1']; $Note = $_POST['Note']; mysqli_query($db, "UPDATE ipd SET History='$History', Examination='$Examination', Investigation='$Investigation', Diagnosis='$Diagnosis', Operation='$Operation', OTnote='$OTnote', Condition1='$Condition1', Advise ='$Advise', Treatment='$Treatment', Note='$Note' WHERE ipd_id=$ipd_id"); $_SESSION['message'] = "Discharge saved Successfull !"; header('location: ../doctor/discharge.php'); } $results = mysqli_query($db, "SELECT * FROM IPD "); ?> Edited May 8 by Barand Coding was missed Hi guys
I am using the code below to show distinct months using one query then for each month I am trying to show a list of fixtures for the month, the problem I have is only one month is showing.
where am i going wrong?
<?php //find distinct months $sql="SELECT DISTINCT MONTH( match_date ) AS MONTH FROM tbl_fixtures WHERE season_id =$current_season UNION SELECT DISTINCT MONTH( match_date ) AS MONTH FROM tbl_gp WHERE season_id =$current_season"; $result=mysqli_query($dbConn, $sql); if(mysqli_num_rows($result)>0){ while($row=mysqli_fetch_assoc($result)){ $month=$row['MONTH']; echo '<div class="fixtureMonth"> <h2>'.$months[$month].'</h2> </div> <div class="fixtures">'; //find fixtures for month $sql="SELECT Opposition, match_date, competition, tbl_clubs.club_name AS club, image, HomeAway, team, opposition_points, points FROM tbl_fixtures INNER JOIN tbl_clubs ON tbl_fixtures.club = tbl_clubs.club_id WHERE season_id =$current_season and MONTH(match_date)=$month UNION SELECT Opposition, match_date, \"SGP\" AS competition, \"SGP\" AS club, \"sgp.png\" AS image, \"\" as HomeAway, \"\" as team, \"\" as opposition_points, points FROM tbl_gp WHERE season_id =$current_season and MONTH(match_date)=$month ORDER BY match_date"; $result=mysqli_query($dbConn,$sql)or die(mysqli_error($dbConn)); if(mysqli_num_rows($result)==0){ echo no_fixtures_found; } else{ echo '<table class="fixturesTable">'; while($row=mysqli_fetch_assoc($result)){ echo'<tr> <td>'.date("d-M-Y",strtotime($row['match_date'])).'</td> <td><img src="'.$shopConfig['url'].'images/'.$row['image'].'"/></td> <td>'.$row['Opposition'].'</td> <td>'.$row['HomeAway'].'</td> <td><b>'.$row['team'].'</b>-'.$row['opposition_points'].'</td> <td>'.$row['team'].'</td> </tr>'; } echo '</table>'; } echo '</div>'; } } ?> |