PHP - Updating A Tiny Int
I am trying to update a tiny int i have the if statement which says when tiny int is 1 echo closed and when tiny int 0 echo open. The problem is i am trying to query the result in a drop down but the option of status Closed doesnt appear.
Code: [Select] <?php //connect to database $con=mysql_connect("localhost","root","15AE@ea27") or die("couldn't connect to mysql"); //select database $db=mysql_select_db("ac_res",$con) or die("database not found"); //get ID to Edit $id = $_GET['id']; //Query Fields to edit $sql = 'SELECT * FROM `ac_reservation` WHERE `id` = "'.$id.'"'; $query = mysql_query($sql) or die("Couldn't execute query. ". mysql_error()); $results = mysql_fetch_array($query); $status = 'status'; //Query the waiter table $waiter=mysql_query("SELECT fname FROM waiter") or die("query error"); ?> <form id="edituser" name="edituser" method="post" action="editresexec.php"> <table width="300" border="0" align="center" cellpadding="2" cellspacing="0"> <tr> <th> </th> <td><input name="id" type="hidden" class="textfield" value= <?php echo $results[id]?> /> </td> </tr> <tr> <th>First Name </th> <td><input name="fl_name" id="keyboard2" type="text" class="textfield" value= <?php echo $results[fl_name]?> /> </td> </tr> <tr> <th>Number of People</th> <td><input name="n_people" id="keyboard3" type="text" class="textfield" value= <?php echo $results[n_people]?> /> </td> </tr> <tr> <th>Table Number</th> <td><input id="t_number"name="t_number" type="text" class="textfield" value= <?php echo $results[t_number]?> /></td> </tr> <tr> <th>Waiter</th> <td><?php echo "<select name=waiter>"; while($r=mysql_fetch_array($waiter)) { //echo waiter name echo "<option value='".$r['fname']."'>".$r['fname']."</option>"; } echo "</select>"; ?> </td> </tr> <tr> <th>Status</th> <td><?php //If statement if($rows['status'] == 1) { $status = "Close"; } else $status = "Open"; //Drop Down Menu For Status echo "<select>"; echo "<option value='".$status."'>".$status."</option>"; echo "</select>"; ?> </td> </tr> <tr> <td> </td> <td><input type="submit" name="Update" value="Update" /></td> </tr> </table> </form> Similar TutorialsHello nice php experts :-) I've just changed the theme on my wordpress page but wish to add a couple of links to my non-wordpress pages to it. This is the line of code where I wish to add some more links. I'm going to use the page-link class to format the links but I'm not sure where I would add the extra divs in amongst all of those commas and brackets. <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', '' ), 'after' => '</div>' ) ); ?> Any help is gratefully accepted. I use the following code to create a 48x7 array for my application: Code: [Select] // Loop through each time division for($i=0; $i<$div; $i++) { // Loop through the week we're displaying for($j=0;$j<$dayPerPage; $j++) { $dateArray = getDate( mktime( 0, 0, 0, date("m"), date("d")+$j+$dateOffset, date("Y") ) ); $date = sprintf('%04d-%02d-%02d',$dateArray["year"],$dateArray["mon"],$dateArray["mday"]); $datetime[]="$time|$date"; list($start_date) = explode('|',$datetime[1]); list($end_date) = explode('|',end($datetime)); } $min += $step_size; if($min >= 60) { $min = 0; $hr++; } $time = sprintf('%02d:%02d:00',$hr,$min); }Now, I'm under the assumption that list($start_date) and list($end_date) should give me the beginning and ending dates inside the array (say 2011-10-01 and 2011-10-07), but instead I get the beginning and ending times in it ('00:00:00' AND '23:30:00'). Could someone clarify what I'm doing wrong and how I can fix it? I'm really new to php EDIT: Sorry... used the wrong tags for the code the first time around. Fixed. preg_match_all('/(www.DOMAIN.com\/([^"]+))\"/i', $html, $matches); How do you make this match any URL on the domain including URLs with ? = & type of characters. Sorry in advance for my lack of knowledge. I am not trained and I know almost zero about site building. On my site there is a tiny rectangle that is showing up on a drop down menu... It hasn't always been there. I'm pretty sure it showed up after upgrading to the newest Internet Explorer. I've been staring at it and finally decided to figure out what it is doing there.... Please, any and all help will be greatly appreciated. The rectangle is not hindering the site, it is just an eye sore. Thanks in advance! Yelhsa See Attachment for Screenshot. Link to Site: www.georgiafarmandforest.com Coding (this is the drop down menu part of the coding, I don't know if you need more than this.... If so, does viewing the source work?): Menu1=new Array("Home","index.php","",0,20,140); Menu2=new Array("Counties","#","",11,0,140); Menu2_1=new Array("Bartow","bartow.php","",0,20,140); Menu2_2=new Array("Carroll","carroll.php","",0,20,0); Menu2_3=new Array("Catoosa","catoosa.php","",0,20,140); Menu2_4=new Array("Chattooga","chattooga.php","",0,20,140); Menu2_5=new Array("Dade","dade.php","",0,20,140); Menu2_6=new Array("Floyd","floyd.php","",0,20,140); Menu2_7=new Array("Gordon","gordon.php","",0,20,140); Menu2_8=new Array("Murray","murray.php","",0,20,140); Menu2_9=new Array("Polk","polk.php","",0,20,140); Menu2_10=new Array("Walker","walker.php","",0,20,140); Menu2_11=new Array("Whitfield","whitfield.php","",0,20,80); Menu3=new Array("Resources","resources.php","",0,0,140); Menu4=new Array("Contact Us","contact.php","",0,20,140); Menu5=new Array("Submit Land Wanted","submit.php","",0,0,160); So, I am making a CMS for my school and I am having some trouble. It's a magazine sort of CMS and what I want is that when you click on a certain thing it continues onto the next page. Through the CMS you can create pages - when you do this each page gets a unique PID. To access the pages you have to enter the PID on the end of the URL, e.g. : http://www.myschool.com/magazine/index.php?pid=x. What I need is a code that when an image gets clicked the PID number in the URL goes up by one. Thanks Hi, I'm using php to access the mysql database using mysqli and I have a field on my table called "timestamp" and it's set as a timestamp and has current_time (I think in phpmyadmin it was a tick option so I clicked it) and when I update that row in my table the field "timestamp" doesn't update with the timestamp from when it was last updated/modified. I thought the field option timestamp automatically did that? I'm guessing not.. is there a way I can update the timestamp with the current time in my query? $query1 = "select * from movies where title = '".$title."' ;"; $result1 = mysql_query($query1) or die('Could Not Execute The Query'); while ($row = mysql_fetch_assoc($result1) ) { for($f=0; $f<$parts[$current_k]; $f++ ) { touch("$base_folder/{$hos}/".$linking[$sum].".php"); $old_part_href = $row['href_parts']; $updated_part = $old_part_href.$new; $query_href = 'update movies set href_parts = \''.$updated_part.'\''; mysql_query($query_href) or die('COULD NOT EXECUTE THE QUERY FOR PARTS HREF'); $new = "{$base_folder}/{$hos}/".$linking[$sum].".php"; $sum++; } } what i am trying to do is take the value of href_parts and add the new href of the page to the existing value on the href_parts and update the href_parts field in my db.. but i am not getting the desired results.. all i am getting in the db is the last value that is passed in the loop in the db.. i want to save the values which are exisiting in the db and add the newly created values to itt.. can anyone help please.. I'm back, I have a code that based on my understanding should work, but needless to say doesn't <?php $sql ="select * from `piprice`"; $result = mysql_query($sql); $count = mysql_num_rows($result); echo "<table border=1><tr><td>Product Name</td><td>Item ID</td><td>Price</td><td>Enabled</td>"; echo "<form action=main.php?id=test1.php method=post>"; while ($row = mysql_fetch_array($result)) { echo "<tr><td>".$row['product name']."</td>"; echo "<td>".$id[] = $row['item id'];$row['item id']."</td>"; echo "<td>".$row['price']."</td>"; $enabled[] = $row['enabled']; echo"<td><select name=".$enabled.">< <option Value=".$row['enabled'].">".$row['enabled']."</option> <option Value=Yes>Yes</option> <option Value=No>No</option> /select></td</tr>"; } echo "<input name=submit type=submit value=Update>"; echo "</form></table>"; if(isset($_POST['submit'])) { for($i=0;$i<$count;$i++){ $sql1="UPDATE `piprice` SET `enabled` = '$enabled[$i]' WHERE `item id` ='$id[$i]'"; $result1=mysql_query($sql1) or die (mysql_error()); } } ?> Basically I want to be able to pick yes/no and have it update in the database. One a side note is there a good site for me to learn php on (I just know the basics) besides asking 101 questions here $sqld = "SELECT * FROM orders WHERE `id`='$delete' AND `name`='$inf2[name]' AND `email`='$inf2[email]' LIMIT 1"; $csql = $db->query($sqld); $ccheck = $csql->fetch(PDO::FETCH_NUM); $cinf = $csql->fetch(PDO::FETCH_ASSOC); $quantity = $cinf[quantity]; $code = $cinf[code]; $stmt11 = $db->prepare('UPDATE feeds SET quantity=quantity-:quantity WHERE code=:code'); $stmt11->bindValue(':quantity', $quantity, PDO::PARAM_STR); $stmt11->bindValue(':code', $code, PDO::PARAM_STR); $stmt11->execute(); $id = $delete; $name = $inf2[name]; $stmt2 = $db->prepare("DELETE FROM orders WHERE id=:id AND name=:name"); $stmt2->bindValue(':id', $id, PDO::PARAM_STR); $stmt2->bindValue(':name', $name, PDO::PARAM_STR); $stmt2->execute();OK, i have just been told i should start using PDO instead of mysql to update my tables. This code works to delete the order but doesn't update the feeds section. All this is new to me so far and i think i am getting the hang of it. Should i still be using the quantity=quantity-:quantity or is there another way to do it with PDO? Sorry, i posted this in the wrong forum. Hope someone here can help until it's moved Edited by Self_Taught_Still_Learning, 30 May 2014 - 03:30 PM. The client provides name/value pairs which are used to update something and I am currently using switch statements to direct the action based on the provided name, however, it is becoming increasingly more complicated. Are there any standard approaches to doing so? I am thinking of doing the following. Any concerns? Thanks $c['fooService'] = function ($c) { return new Foo\FooService( new Foo\FooMapper(), new ApiConnector(), new Foo\FooNameValueUpdater(), ); }; $app->put('/foo/{id:[0-9]+}', function (Request $request, Response $response, $args) { return $this->fooResponder->update($response, $this->fooService->update($args['id'], $request->getParsedBody())); }); Class FooService extends BarService { public function __construct($mapper, $updater, $apiConnector) { $this->mapper = $mapper; $this->apiConnector = $apiConnector; $this->updater = $updater; } public function update($id, $params) { //$params=['name'=>'property1name', 'value'=>123] $this->updater->$params['name']($id, $params['value'], $this); } public function updateSomeStandardAction($id, $value, $propertyName) { //some code... $this->mapper->bla($id, $value, $propertyName); } public function updateSomeOtherStandardAction($id, $value, $propertyName) { //some code... $this->apiConnector->bla($id, $value, $propertyName); } } Class FooNameValueUpdater extends BarNameValueUpdater { public function property1name($id, $value, $service) { $this->updateSomeStandardAction($id, $value, $service, 'property1name'); } public function property2name($id, $value, $service) { $this->updateSomeStandardAction($id, $value, $service, 'property2name'); } public function property3name($id, $value, $service) { $this->updateSomeStandardAction($id, $value, $service, 'property3name'); } public function property4name($id, $value, $service) { $this->updateSomeStandardAction($id, $value, $service, 'property4name'); } protected function updateSomeStandardAction($id, $value, $service, $propertyName) { //some code... $service->updateSomeStandardAction($id, $value, $propertyName); } protected function updateSomeOtherStandardAction($id, $value, $service, $propertyName) { //some code... $service->updateSomeOtherStandardAction($id, $value, $propertyName); } }
Sorry maybe a stupid question but Ive made a cron and its not updating the players cash as it should, can anyone spot why? I've looked but just cannot see it, Thanks appreciate your time for looking. Code: [Select] <?php include("server.php"); $sql = "SELECT * FROM players"; $que = mysql_query($sql); while($res=mysql_fetch_array($que)) { $sql2 = "SELECT * FROM players WHERE id = '$res[id]'"; $que2 = mysql_query($sql2) or die(mysql_error()); $res2 = mysql_fetch_array($que2); $hoes = $res2['Hoes']; $hobedding = $res2['MaxHoes']; $incomemod = $res2['HoIncome']; $morale = $res2['HoesMorale']; if ($hoes < $hobedding) { $income = (250 * $hoes * $incomemod * $morale); } else { if ($hoes > $hobedding) { $income = (250 * $hobedding * $incomemod * $morale) + (125 * ($hoes - $hobedding) * $incomemod * $morale); } $sql5 = "UPDATE players SET cash = cash + '$income' WHERE id = '$res[id]'"; mysql_query($sql5) or die(mysql_error()); } } ?> ok it updates the posts table , but not the notifications table , helP! Code: [Select] <?php include("../includes.php"); $session =$logOptions_id; if($session) { $id = $_POST['id']; if(!$id) { $id = $session; } $post = mysql_real_escape_string($_POST['post']); $date = mktime(); $action_type = 0; mysql_query("INSERT INTO posts SET to_id='$id',from_id='$session',post='$post',type='$action_type',date='$date'"); $post_id = mysql_insert_id(); $query = mysql_query("SELECT id,to_id,from_id,post,type,state,date FROM posts WHERE id='$post_id' AND state='0' ORDER BY id DESC LIMIT 15"); print posts($query, "newPost"); if($id!=$session) { mysql_query("INSERT INTO notifications SET user_id='$id', from_id='$session', post_id='$post_id', action_type='$action_type', date='$date'"); } } ?> Hey i have this code that should update database on submit of a form. i have multiple rows selected from a database and i need to be able to update each row individually...however currently as the code stands it updates all rows with the data entered into the bottom row. i dont know how to solve this its very frustrating could someone take a look and help me? here is the code <?php session_start(); ?> <a href="adminlogout.php">Logout</a><br /> <?php $id = $_GET['id']; if(!isset($_SESSION['myusername'])) { header("location:adminlogin.php"); } $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $db = 'bank'; $conn = mysql_connect($dbhost,$dbuser,$dbpass); mysql_select_db($db); if(isset($_POST['submit'])){ $select = mysql_query("SELECT * FROM accounts WHERE cusid=$id"); $row3 = mysql_fetch_array($select); $update = mysql_query("UPDATE accounts SET balance='".$_POST['balance']."', type='".$_POST['type']."', name='".$_POST['name']."', active='".$_POST['active']."' WHERE cusid=$id"); } $result = mysql_query("SELECT * FROM customer WHERE cusid=$id"); $row2 = mysql_fetch_array($result); echo $row2['name'] . "'s bank accounts" . "<br><br>"; $result2 = mysql_query("SELECT * FROM accounts WHERE cusid=$id"); echo "<form method='post' action='accounts.php?id=$id'>"; while($row = mysql_fetch_array($result2)) { echo "<input type='text' name='accno' style='background-color:lightgrey;' readonly='readonly' value='$row[accno]'>" . "<input type='text' name='name' value='$row[name]'>"; if($row['type'] == "Current"){echo"<select name='type'>" . "<option selected='Selected'>Current</option>" . "<option>Savings</option>" . "</select>";} else{echo"<select name='type'>" . "<option selected='Selected'>Savings</option>" . "<option>Current</option>" . "</select>";} echo"<input type='text' name='balance' value='$row[balance]'>"; if($row['active'] == "No"){ echo "<select name='active'>" . "<option value='No' selected='selected'>No</option>" . "<option value='Yes'>Yes</option>" . "</select>";} elseif($row['active'] == "Yes"){echo "<select name='active'>" . "<option value='Yes' selected='selected'>Yes</option>" . "<option value='No'>No</option>" . "</select>";} echo "<input type='submit' name='submit' value='Update'>" . "<br>"; } echo "</form>"; ?> well here my page i tryed and tryed to get it working but it shows the data but it dont update it Code: [Select] [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"> <head><?php include "../config.php"; $id = $_GET['id']; $con = database_connect(); $sql = "SELECT * FROM anime1 WHERE animeid ='$id'"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { $title = $row['title']; $type = $row['type']; $episode = $row['episode']; $year = $row['year']; $genre = $row['genre']; $status = $row['status']; $summary = $row['summary']; $pictures = $row['pictures']; }mysql_query($sql) or exit(mysql_error()); mysql_close($con); ?> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(".flip").click(function(){ $(".panel").slideToggle("slow"); }); }); </script> <style type="text/css"> </style> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Transdmin Light</title> <!-- CSS --> <link href="style/css/transdmin.css" rel="stylesheet" type="text/css" media="screen" /> <!--[if IE 6]><link rel="stylesheet" type="text/css" media="screen" href="style/css/ie6.css" /><![endif]--> <!--[if IE 7]><link rel="stylesheet" type="text/css" media="screen" href="style/css/ie7.css" /><![endif]--> <!-- JavaScripts--> <script type="text/javascript" src="style/js/jquery.js"></script> <script type="text/javascript" src="style/js/jNice.js"></script> </head> <body> <div id="wrapper"> <!-- h1 tag stays for the logo, you can use the a tag for linking the index page --> <h1><a href="#"><span>Transdmin Light</span></a></h1> <!-- You can name the links with lowercase, they will be transformed to uppercase by CSS, we prefered to name them with uppercase to have the same effect with disabled stylesheet --> <ul id="mainNav"> <li><a href="#">DASHBOARD</a></li> <!-- Use the "active" class for the active menu item --> <li><a href="./anime.php" class="active">Anime</a></li> <li><a href="#">DESIGN</a></li> <li><a href="#">OPTION</a></li> <li class="logout"><a href="#">LOGOUT</a></li> </ul> <!-- // #end mainNav --> <div id="containerHolder"> <div id="container"> <div id="sidebar"> <ul class="sideNav"> <li><?php echo $lbox1 ?></li> <li><?php echo $lbox2 ?></li> <li><?php echo $lbox3 ?></li> <li><?php echo $lbox4 ?></li> <li> <?php echo $lbox5 ?></li> <li><?php echo $lbox6 ?></li> </ul> <!-- // .sideNav --> </div> <!-- // #sidebar --> <!-- h2 stays for breadcrumbs --> <h2><a href="#">Anime</a> » edit » <?php echo "$title"; ?></h2> <div id="main"> <form action="<?php echo $_SERVER['PHP_SELF']."?id=$id" ; ?>" method="post" class="jNice"> <h3>Editing <?php echo "$title"; ?>, when finished click submit</h3> <fieldset> <p> <label>Series Title -- (Put the Title of the Series you are adding into here)</label> <input name="title" type="text" class="text-long" id="title" value="<?php echo $title ?>" /> </p> <p> <label>Type -- (Put what type of anime is it?)</label> <select name="type" id="type"> <option selected="selected">Select one</option> <option>TV Series</option> <option>OVA</option> <option>TV Special</option> <option>Movie</option> <option>Web</option> <option>DVD Special</option> <option>Other</option> </select> </p> <p> <label>Episodes -- (How many Episode are there?)</label> <input name="episode" type="text" class="text-long" id="episode" value="<?php echo $episode ?>" /> </p> <p> <label>Year -- (What year was the anime release in?)</label> <input name="year" type="text" class="text-long" id="year" value="<?php echo $year ?>" /> </p> <p> <label>genre <a href="./genre">(click this for the list and FAQ for adding in genre)</a></label> <input name="genre" type="text" class="text-long" id="genre" value="<?php echo $genre ?>" /> </p> <p> <label>status -- (What Is the status of the anime, Completed, Ongoing or Stalled)</label> <select name="status" id="status"> <option selected="selected">Select one</option> <option>Complete</option> <option>Ongoing</option> <option>Stalled</option> </select> </p> <p> <label>Summary -- (Put in the Summary for the anime)</label> <textarea name="summary" cols="1" rows="1" id="summary"><?php echo $summary ?></textarea> </p> <p> <label>Pictures -- (link to the Anime Pictures you upladed)</label> <input name="pictures" type="text" class="text-long" id="pictures" value="<?php echo $pictures ?>" /> </p> <?php $con = database_connect(); $sql="UPDATE anime1 SET title='$title', type='$type', episode='$episode', year='$year', genre='$genre', status='$status', summary='$summary', pictures='$pictures' WHERE animeid = '$id'"; $con = database_connect(); $title = $_POST['title']; $type = $_POST['type']; $episode = $_POST['episode']; $year = $_POST['year']; $genre = $_POST['genre']; $status = $_POST['status']; $summary = $_POST['summary']; $pictures = $_POST['pictures']; $title = mysql_real_escape_string($title); $type = mysql_real_escape_string($type); $episode = mysql_real_escape_string($episode); $year = mysql_real_escape_string($year); $genre = mysql_real_escape_string($genre); $status = mysql_real_escape_string($status); $summary = mysql_real_escape_string($summary); $pictures = mysql_real_escape_string($pictures); error_reporting(-1); if (!mysql_query($sql,$con)) { die('Error adding anime database: ' . mysql_error()); } ?> <h3> </h3> <?php $con = database_connect(); $sql1 = "SELECT * FROM episodea WHERE animeid = '$id' UNION ALL SELECT * FROM episodeb WHERE animeid = '$id'"; $result1 = mysql_query($sql1); while ($row = mysql_fetch_assoc($result1)) { $ep = $row['ep']; $epname = $row['epname']; $animeid = $row['animeid']; $video = $row['video']; $video2 = $row['video2']; $video3 = $row['video3']; mysql_query($sql) or exit(mysql_error()); echo " <div class=\"panel\">\n"; echo "<p>\n"; echo " <label>Episodes -- (When this box says Anime episode finished, you have added in all the episodes)</label>\n"; echo " <input name=\"ep\" type=\"text\" class=\"text-long\" id=\"ep\" value=\" $ep\" readonly=\"readonly\" />\n"; echo " </p>\n"; echo " <p>\n"; echo " <label>Episodes Name-- (What is the name of the episode you are adding? --- If the episodes has no name enter episode number)</label>\n"; echo " <input name=\"epname\" type=\"text\" class=\"text-long\" id=\"epname\" value=\" $epname\" />\n"; echo " </p>\n"; echo " <p>\n"; echo " <label>Viewable -- (Is the episode your are adding in SUBBED or DUBBED or RAW?)</label>\n"; echo " <select name=\"viewable\" id=\"viewable\">\n"; echo " <option selected=\"selected\">Select one</option>\n"; echo " <option>SUBBED</option>\n"; echo " <option>DUBBED</option>\n"; echo " <option>RAW</option>\n"; echo " </select>\n"; echo " </p>\n"; echo " <p>\n"; echo " <label>Video 1 -- (enter the embed code for the episode you are adding in)</label>\n"; echo " <textarea name=\"video\" cols=\"1\" rows=\"1\" id=\"video\"> $video</textarea></p>\n"; echo " <p>\n"; echo " <label>Video 2 -- ( If you have a 2ed embed code </label>\n"; echo " <textarea name=\"video1\" cols=\"1\" rows=\"1\" id=\"video1\"> $video2</textarea>\n"; echo " </p>\n"; echo " <p>\n"; echo " <label>Video 3 --( If you have a 3ed embed code </label>\n"; echo " <textarea name=\"video4\" cols=\"1\" rows=\"1\" id=\"video4\"> $video3</textarea>\n"; echo "<h3>\n"; echo "<a href=\"#submit\">IF you finished editing ep, click me to go to submit button</a></h3>\n"; echo " </p>\n"; echo "</div>\n"; echo " \n"; echo " <br />"; echo "<br />"; echo "<p class=\"flip\">Click here to edit all Episodes For $title </p>\n"; echo " <br />"; echo "<br />"; } ?> <h3> remember to click submit before changing the page</h3> <h3> </h3> <h3> <a name="submit" id="submit"></a> <input type="submit" value="Submit Query" /> </h3> </fieldset> </form> </div> <!-- // #main --> <div class="clear"></div> </div> <!-- // #container --> </div> <!-- // #containerHolder --> <p id="footer">Feel free to use and customize it. <a href="http://www.perspectived.com">Credit is appreciated.</a></p> </div> <!-- // #wrapper --> </body> </html> [/php] i have this small problem trying to update the database.... what i have is a members site in which they can view a variety of topics, however i want the user to be able to say delete a topic they are not interested in but still keep that topic open to other users who have not blocked it I'm tying to figure out how to do this, i initially had the following code: $update_db = mysql_query("UPDATE topics SET view='2' WHERE topicID='$topicID'") or die(mysql_error()); I had it set to to 2 meaning that all the topics that were set to 1 were visible to the user, only those they blocked were set to 2 and only be blocked to those users who blocked them not everyone The problem with that was that it blocked it to everyone Can anyone help me? Okay, I have a useredit page in where a user can manage their account info. All the text field and SQL connections work fine, and they all update perfectly. But when I go ahead and add my own text field (first name) and hit submit, it says success - but in my SQL it hasn't actually updated ... What the Ef? Here are my snippets of my codes: --useredit.php-- <form action="process.php" method="POST"> <input type"text" name"firstname" value="<? if($form->value("firstname") == ""){ echo $session->userinfo['firstname']; }else{ echo $form->value("firstname"); } ?>"> <input type="hidden" name="subedit" value="1"> <input type="submit" value="Edit Account"> --process.php-- function procEditAccount(){ global $session, $form; /* Account edit attempt */ $retval = $session->editAccount($_POST['curpass'], $_POST['newpass'], $_POST['email'], $_POST['firstname']); /* Account edit successful */ if($retval){ $_SESSION['useredit'] = true; header("Location: ".$session->referrer); } --session.php-- function editAccount($subcurpass, $subnewpass, $subemail, $subfirstname){ global $database, $form; if($subfirstname){ $database->updateUserField($this->username,"firstname",$subfirstname); } --database.php-- function updateUserField($username, $field, $value){ $q = "UPDATE ".TBL_USERS." SET ".$field." = '$value' WHERE username = '$username'"; return mysql_query($q, $this->connection); } If you need to see more code, let me know. Would appreciate the help, thanks! Ollie! Hi everyone, I need a little help on making forms that automatically update as you select stuff, For example if you was to select something from a drop down menu, The page will update, And show a new drop down box that will list products compatible with the fiirst product, I could easily add these to arrays, Then the script could just pull from each array. Also I don't know if this will need any javascript... I am no good at that so please warn me if it does! Any kind of help would be highly appreciated, Thanks, Gergy. why is it not updating? <?php $_POST['email']; $_POST['submit']; if (isset($_POST['submit'])) { /*$sql =" UPDATE class_members SET email ='".$_POST['email']."', WHERE S_UID ='".$_POST['mem_id']."' ";*/ $result = mysql_query("UPDATE class_members SET email ='".$_POST['email']."', WHERE mem_id='".$_POST['mem_id']."'") or die(mysql_error()); } ?> Hello, I have been staring at my screen for the last couple of days and have finally run out of solutions. I have the code below where the data is generated form another page. The correct data is displayed but for some reason when I try to alter any data it does not work. I simply get the message, "Your profile has been successfully updated..." but nothing has been changed in the database. I think the code is not connecting to the correct table in the database.. I fail to see why this would be. Any help greatly appreciated. Code: [Select] <?php error_reporting(E_ALL); session_start(); ?> <?php require_once('appvars.php'); require_once('connectvars1.php'); // Connect to the database $dbc = mysqli_connect(DB_Host, DB_User, DB_Password, DB_Name); if (!isset($_GET['user_id'])) { $query = "SELECT * FROM antique WHERE user_id = '" . $_SESSION['user_id'] . "'"; } else { $query = "SELECT * FROM antique WHERE user_id = '" . $_GET['user_id'] . "'"; } $data = mysqli_query($dbc, $query); if (mysqli_num_rows($data) == 1) { $row = mysqli_fetch_array($data); } ?> <?php require_once('appvars.php'); require_once('connectvars1.php'); // Make sure the user is logged in before going any further. if (!isset($_SESSION['user_id'])) { echo '<p class="login">Please <a href="login1.php">log in</a> to access this page.</p>'; exit(); } // Connect to the database $dbc = mysqli_connect(DB_Host, DB_User, DB_Password, DB_Name); if (isset($_POST['submit'])) { // Grab the profile data from the POST $name = mysqli_real_escape_string($dbc, trim($_POST['name'])); $phone = mysqli_real_escape_string($dbc, trim($_POST['phone'])); $address1 = mysqli_real_escape_string($dbc, trim($_POST['address1'])); $address2 = mysqli_real_escape_string($dbc, trim($_POST['address2'])); $postcode = mysqli_real_escape_string($dbc, trim($_POST['postcode'])); $webadd = mysqli_real_escape_string($dbc, trim($_POST['webadd'])); $email = mysqli_real_escape_string($dbc, trim($_POST['email'])); $old_picture = mysqli_real_escape_string($dbc, trim($_POST['old_picture'])); $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']; $username = mysqli_real_escape_string($dbc, trim($_POST['username'])); $user_id = mysqli_real_escape_string($dbc, trim($_POST['user_id'])); if (!empty($_FILES['new_picture']['tmp_name'])) {list($new_picture_width, $new_picture_height) = getimagesize($_FILES['new_picture']['tmp_name']); } //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['new_picture']['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)) { } } 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>'; } } $error = false; // Update the profile data in the database if (!$error) { if (!empty($name)&& !empty($phone) && !empty($address1) && !empty($address2)) { // Only set the picture column if there is a new picture if (!empty($new_picture)) { //if (!empty($postcode)){ $query = "UPDATE antique SET name = '$name', phone = '$phone', address1 = '$address1', address2 = '$address2', postcode = '$postcode', " . " email = '$email', webadd = '$webadd', picture = '$new_picture', username = '$username' WHERE user_id = '" . $row['user_id'] ."'"; }} else { $query = "UPDATE antique SET name = '$name', phone = '$phone', address1 = '$address1', address2 = '$address2', postcode = '$postcode', " . " email = '$email', webadd = '$webadd', username = '$username' WHERE user_id = '" . $row['user_id'] ."'"; } mysqli_query($dbc, $query) or die("<br>Query $query<br>Failed with error: " . mysqli_error($dbc) . '<br>On line: ' . __LINE__); // Confirm success with the user echo '<p>Your profile has been successfully updated. Would you like to <a href="viewprofile4.php">view your profile</a>?</p>'; mysqli_close($dbc); exit(); } else { echo '<p class="error">You must enter all of the profile data (the picture is optional).</p>'; } } // End of check for form submission else { // Grab the profile data from the database $query="SELECT * FROM antique WHERE user_id= '" . $row['user_id'] . "'"; $data = mysqli_query($dbc, $query); $row = mysqli_fetch_array($data); if ($row != NULL) { $name = $row['name']; $phone = $row['phone']; $address1 = $row['address1']; $address2 = $row['address2']; $postcode = $row['postcode']; $email = $row['email']; $webadd = $row['webadd']; $old_picture = $row['picture']; $username = $_SESSION['username']; $user_id = $row['user_id']; } else { echo '<p class="error">There was a problem accessing your profile.</p>'; } } mysqli_close($dbc); ?> <form enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo MM_MAXFILESIZE; ?>" /> <fieldset> <legend>Personal Information</legend> <label for="name">Name:</label> <input type="text" id="name" name="name" value="<?php if (!empty($name)) echo $name; ?>" /><br /> <label for="phone">Phone:</label> <input type="text" id="phone" name="phone" value="<?php if (!empty($phone)) echo $phone; ?>" /><br /> <label for="address1">Address1:</label> <input type="text" id="address1" name="address1" value="<?php if (!empty($address1)) echo $address1; ?>" /><br /> <label for="address2">Address2:</label> <input type="text" id="address2" name="address2" value="<?php if (!empty($address2)) echo $address2; ?>" /><br /> <label for="postcode">Postcode:</label> <input type="text" id="postcode" name="postcode" value="<?php if (!empty($postcode)) echo $postcode; ?>" /><br /> <label for="email">Email:</label> <input type="text" id="email" name="email" value="<?php if (!empty($email)) { echo $email; } else { echo 'No email entered';} ?>" /><br /> <label for="webadd">Web address:</label> <input type="text" id="webadd" name="webadd" value="<?php if (!empty($webadd)) { echo $webadd; } else { echo 'No web entered';} ?>" /><br /> <input type="hidden" name="old_picture" value="<?php if (!empty($old_picture)) echo $old_picture; ?>" /> <label for="new_picture">Pictu </label> <input type="file" id="new_picture" name="new_picture" /> <?php if (!empty($old_picture)) { echo '<img class="profile" src="' . MM_UPLOADPATH . $old_picture . '" alt="Profile Picture" style: height=100px;" />'; } ?> <br /> <label for="address2">username:</label> <input type="text" id="username" name="username" value="<?php if (!empty($username)) echo $username; ?>" /><br /> <label for="user_id">User ID:</label> <input type="text" id="user_id" name="user_id" value="<?php echo '' . $row['user_id'] . '' ; ?>" /><br /> </fieldset> <input type="submit" value="Save Profile" name="submit" /> </form> <?php echo('<p class="login">You are logged in as ' . $_SESSION['username'] . '. <a href="logout3.php">Log out</a>.</p>'); echo '<class = "label">USER ID: ' . $row['user_id'] . ''; ?> <p><a href="index.php">Return to homepage</a></p> <?php require_once('footer.php'); ?> </body> </html> HI there im having a problem with updating one table with anopther tables contents atm i have this code: Code: [Select] if($sql) { $msg = "Taxi Accepted sucessfully."; mysql_query("INSERT INTO user_location ( User_ID,User_Longitude,User_Latitude) SELECT User_ID,User_Longitude,User_Latitude FROM quotes") or die (mysql_error()); } else { $msg = "Taxi not Accepted sucssfully try again."; echo "$msg"; } The error message im getting is :Duplicate entry '1' for key 1 :S any help at all Thank You |