Jump to content

Search the Community

Showing results for tags 'update'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (Dreamweaver, Zend, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 13 results

  1. So i have this following code that doesn't work <?php $id = $_GET['id']; $data = $_GET['data']; $key = "Password"; mysql_query("update contest_data set '$key'='$data' where Contest_Data_ID='$id'") ?> it doesn't work unless i put it like this <?php $id = $_GET['id']; $data = $_GET['data']; $key = "Password"; mysql_query("update contest_data set `Password`='$data' where Contest_Data_ID='$id'") ?> is there a way to put the `` when setting the $key value i even tired to put $key = "`Password`" and that doesn't work. Also $key="password" is going to be $key= $_GET['key'] but for now i put it like this so i can test it out
  2. Here's what I am trying to do. Retrieve "title" and "slug title" from all the rows in a table. Update them with new "title", "slug title" and "brand name". Here's my query. It updates the table with the brand names for each row. But for some reason, it removes the title and slug title from all the rows in the table. Is there a reason why it's doing that? function getIt($var) { $pos = strpos($var, ' - '); echo(substr($var, $pos+3)."\n"); } if(isset($_POST['submit'])) { $get_record = $db->prepare("SELECT * FROM items"); $get_record->execute(); $result_record = $get_record->fetchAll(PDO::FETCH_ASSOC); if(count($result_record) > 0){ foreach($result_record as $row) { $get_item_id = intval($row['item_id']); $get_item_title = trim($row['item_title']); $get_item_title_slug = trim($row['item_title_slug']); $new_title = getIt($get_item_title); $new_title_slug = Output::createSlug($new_title); $brand_name = substr($get_item_title, 0, strpos($get_item_title, ' - ')); $update_record = $db->prepare("UPDATE items SET brand_name = :brand_name, item_title = :item_title, item_title_slug = :item_title_slug WHERE item_id = :item_id"); $update_record->bindParam(':item_id', $get_item_id); $update_record->bindParam(':brand_name', $brand_name); $update_record->bindParam(':item_title', $new_title); $update_record->bindParam(':item_title_slug', $new_title_slug); if(!$update_record->execute()) { $errors[] = 'There was a problem updating the item.'; } } } else { $errors[] = 'No item found.'; } }
  3. Hi guys, I have a problem with my code. It connects with the database but it doesn't execute anything. I am trying to update a value in a table but I really don't know what I am doing wrong. I am trying to change the price based on the meta_value GF-1370 Thank you very much. Here is Table (Taken from myphpadmin) meta_id post_id meta_key meta_value 18538 4356 _sku GF-1370 18541 4356 _price 2.343 and here is my code: <?php $link = mysql_connect('server', 'username', 'password'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_select_db(wordpress_i12dhflgoa); $sql="update `wp_pzvy_postmeta` set `_price` = 5 WHERE `_sku` = 'GF-1370'"; ?>
  4. kaspersky detected vulnerability in my php Affected products: PHP versions earlier than 5.4.39 PHP 5.5 versions earlier than 5.5.23 PHP 5.6 versions earlier than 5.6.7 mine is i guess 5.3 bcz it's in c:\program files (x86)\IIS Express\v5.3\php.exe Solution: Update to the latest version: http://php.net/downloads.php so what am i exactly supposed to do ? can i remove the 5.3 version and install latest 5.6.8? how do i remove 5.3. and how do i install 5.6.8 ? just delete the v5.3 folder and replace it ? which file from http://php.net/downloads.php do i download ? or do i download from http://windows.php.net/download#php-5.6 ? also which one ? i'm on windows 7 using microsoft webmatrix 3 and visual studio express 2013 for web.
  5. I am trying to add a query to my script that updates a value in my database by subtracting "1". When I run the query, I get "Fatal error: Call to a member function free() on boolean in ../path/to/my/script" $sql = "UPDATE table_5 SET chairs = chairs - 1 WHERE chairs > 0 AND chair_model = 'model_33'"; Any idea what I'm doing wrong? Table 5: Chairs | Model Number | 22 | model_33 44 | model_44
  6. I am trying to setup so that I select a name from the dropdown menu (already works) then taking the ID number and using it to update multiple tables. I cannot get it to update anything. I don't really know what I am doing here, I thought based on other coding I have used that this would be simple. Please Help?? <? require('../edb.php'); $aid =$_REQUEST['aid']; if (isset($_POST['Submit'])) { $mysql_query1("UPDATE `adocs_ar_cert` SET Current='N' WHERE AdviserCode='$aid'"); $mysql_query2("UPDATE `adocs_cpd` SET Current='N' WHERE AdviserCode='$aid'"); $mysql_query3("UPDATE `adocs_fds` SET Current='N' WHERE AdviserCode='$aid'"); $mysql_query4("UPDATE `adocs_fsg_profile` SET Current='N' WHERE AdviserCode='$aid'"); $mysql_query5("UPDATE `adocs_sapl` SET Current='N' WHERE AdviserCode='$aid'"); }?>
  7. Hello everyone, I'm create an application where I have member, admin, and superadmin What I'm try to do is superadmin update member to admin, so they can have more privilege. The name of the table is member where I have member, admin account, and i have row call 'rank'. Rank 1 is for member they have access basic stuff and rank 2 they have more privilege. Want the superadmin to type the name of the member and change to rank 2. This is what happening, if I dont put nothing on the text boxes, it said "Please check if you have put the right information." , if i put member and the rank i want to change is says ""User has upgrade to admin", but than when i check my database the member is still a member when i wanted to change to admin. Can anyone see where I'm going home, or what should I change. <form> </form> <form action='<?php htmlentities($_SERVER['PHP_SELF']); ?>' method='POST' enctype='multipart/form-data '> Username: <input class="fontsize" name='user' type='text'/> Rank: <input class="fontsize" name='rank' type='text' /> <br><br> <input class="button" type='submit' name='get' value='Upgrade' /> </form> </h2> <?php if(isset($_POST['get'])) { $username1 = $_POST['user']; $sql_user = mysqli_real_escape_string ($connection, $username1); $rank = $_POST['rank']; $rank = mysqli_real_escape_string ($connection, $rank); $query1 = mysqli_query($connection, "SELECT rank FROM member WHERE username='$sql_user'"); if ($row = mysqli_fetch_array($query1)) { if ($rank == '1') { $data1 = mysqli_query($connection, "UPDATE member SET rank= '1' WHERE username='sql_user'") or die (mysql_error($connection)); echo "User has downgrade to member"; } elseif ($rank == '2') { $data2 = mysqli_query($connection, "UPDATE member SET rank= '2' WHERE username ='sql_user'") or die (mysql_error($connection)); echo "User has upgrade to admin"; } else { echo "Please check if you have put the right information."; } } } ?>
  8. Not sure why I can't get this been trying to figure it out all evening :/ The included smconfig.php contains my database password. Any ideas, I know it's gotta be easy, I must be missing something. PDO connect.php: <?php session_start(); include 'smconfig.php'; $db_host = ""; $db_username = "root"; $db_pass = "$dbpass"; $db_name = "golden_wand"; // PDO CONNECT $db = new PDO('mysql:host='.$db_host.';dbname='.$db_name,$db_username,$db_pass); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); ?> http://www.golden-wand.com/members/tester.php <?php include "../Scripts/connect.php"; $email = "test@gmail.com"; $stmt1 = $db->prepare("SELECT id, activated, username, email, password, token FROM members WHERE email=:email LIMIT 1"); $stmt1->bindParam(':email',$email,PDO::PARAM_STR); $stmt1->execute(); $count = $stmt1->rowCount(); if($count > 0){ while($row = $stmt1->fetch(PDO::FETCH_ASSOC)){ $uid = $row['id']; $username = $row['username']; $email = $row['email']; $hash = $row['password']; $activated = $row['activated']; $token = $row['token']; } } echo "Before: <br>"; echo 'UID = '.$uid; echo '<br>Token = '.$token; echo '<br>Activated = '.$activated; echo '<br>Hash = '.$hash; $activated="1"; $token = "md5($hash)"; try{ $db->beginTransaction(); $updateSQL = $db->prepare("UPDATE members SET activated=':activated' WHERE id=':uid' LIMIT 1"); $updateSQL->bindParam(':activated',$activated,PDO::PARAM_STR); $updateSQL->bindParam(':uid',$uid,PDO::PARAM_INT); $updateSQL->execute(); $db->commit(); echo "<br><br><br><br>Update Successful<br><br><br><br>"; } catch(PDOException $e){ $db->rollback(); echo "<br><br><br><br>Update Failed<br><br><br><br>"; } $stmt2 = $db->prepare("SELECT id, activated, username, email, password, token FROM members WHERE email=:email LIMIT 1"); $stmt2->bindParam(':email',$email,PDO::PARAM_STR); $stmt2->execute(); $count = $stmt2->rowCount(); if($count > 0){ while($row = $stmt2->fetch(PDO::FETCH_ASSOC)){ $uid = $row['id']; $username = $row['username']; $email = $row['email']; $hash = $row['password']; $activated = $row['activated']; $token = $row['token']; } } echo "After: <br>"; echo 'UID = '.$uid; echo '<br>Token = '.$token; echo '<br>Activated = '.$activated; echo '<br>Hash = '.$hash; ?> I own this site: http://www.golden-wand.com/phpfreaks.txt
  9. Hello, i would like to know to how to make this script work. I get information using this link below in index.php, after i get the information i want to insert/update in database information which i don't show on the page self. index.php <?php echo '<a href="example.com?url='. $row['url'] . '&name='. $row['name'] .'&info='. $row['info'] .'&privat='. $row['privat'] .'" target="_blank">Edit</a> ';?> So like this here below i show the information. get_info.php <?php echo $_GET['name']; ?> Which works fine. So now updating the database. $ip_address = $_SERVER['REMOTE_ADDR']; // Ip address works fine $name = $_GET['name']; // not working $r_name = $_POST['$name']; // not working $r_name= 'test'; // this is working. mysql_query("insert into r_test (r_name,r_ip) values('$r_name','$ip_address')") or die(mysql_error()); So how can i get the value and insert in database, only row r_ip is updated with the ip address. I hope i explained it well Thanks in advance.
  10. Hi, I am trying to create an admin page for a local Gym Club to allow an Administrator to be able to update club prices which then show on different screens on the site. I have been able to display the "Prices Admin" page which basically reads a MySQL database table (pricelist), display the description, member price and non-member price and allows the user to update any of these fields. My problem is that when I try writing the data back to the database with the "UPDATE" statement it fails, what I mean is that nothing updates. I have at the moment commented out the actual update statement and put in a "file_put_contents" command" to try and work out what is in the various fields before the UPDATE is run. I find that the display/INPUT works perfectly well but when I do a foreach on the $record array variable I am getting strange results. I may not have explained this very well but here are the relevant sections of my code; // Display and Input section <div id="admin-area"> <br><br> <a class="admin-left">ADMIN (Class Screen Text & Prices)</a> <br> <div class="admin"> <form name="prices" class="pure-form pure-g " action="?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="post"> <fieldset> <textarea id="price-data" name="price-data" rows="5" cols="90"> <?php print(htmlentities($data)) ?> </textarea> <br><br> <label class="pure-u-1-3"> </label> <label class="pure-u-1-3"> <b>Members</b> </label> <label class="pure-u-1-3"> <b>Non-Members</b> </label> <?php $i = 0; while($i < $count) { ?> <input class="pure-u-1-3" id="price_label" type="text" name="records[$i][detail]" value="<?= htmlentities($records[$i]['detail'])?>" maxlength="40" /> <input class="pure-u-1-3" id="price_member" type="text" name="records[$i]" value="<?= htmlentities($records[$i]['price_member'])?>" maxlength="10" placeholder="Member Price" /> <input class="pure-u-1-3" id="price_non" type="text" name="records[$i][nonmember]" value="<?= htmlentities($records[$i]['price_nonmember'])?>" maxlength="10" placeholder="Non Member Price" /> <br> <?php $i++; } ?> <div> <br> <input class="button-input" id="submit" type="submit" name="update" value="Update" /> </div> </fieldset> </form> </div> </div> This results in 11 records displayed on the screen correctly. // In the update section I have removed the actual UPDATE and just used the "put_file_contents()" to show what is in the records array. <?php if (isset($_POST['update'])) { if($_POST['update']=='Update') { file_put_contents('codetest.txt', "File Count - " . $count . "\n", FILE_APPEND); $i = 0; foreach ($_POST[records] as $row) { file_put_contents('codetest.txt', $i . " " . $row['detail'] . " " . $row['member'] . " " . $row['nonmember'] . "\n", FILE_APPEND); $i++; } When run the contents in the codetest.txt is; File Count - 11 0 Party: Airtrack 40.00 30.00 The strange thing here is that the $i = 0 is the first record but the $row['detail'], $row['member'] and $row['nonmember'] details of "Party: Airtrack", 40.00, 30.00 are from record 11 ie the last record. If you want to see the UPDATE code I have been using please let me know and I will post it up here. Any help would be appreciated here. Ian
  11. Hi PHP Freaks. Noobie here. Trying to learn PHP, following lecturesnippets.com PHP lessons. This is lesson 38. This seems like it should be simple, but no matter what I do, I can't get the database to update. Any help would be greatly appreciated. Thanks. Here's my code right now: <html> <head> </head> <body> <?php $con = mysqli_connect("localhost","Eric","******"); if (!$con){ die("Cannot connect:" . mysqli_connect_error()); } mysqli_select_db($con,"snippets"); if (isset($_POST['update'])){ $UpdateQuery = "UPDATE lectures SET Topic = '$_POST', Name='$_POST[name]', Attendance= '$_POST[attendance]' WHERE Topic='$_POST[hidden]'"; mysqli_query($con,$UpdateQuery); }; $sql = "SELECT * FROM lectures"; $myData = mysqli_query($con,$sql); echo "<table border=1> <tr> <th>Topic</th> <th>Name</th> <th>Attendance</th> </tr>"; while($record = mysqli_fetch_array($myData)){ echo"<form action=mydata3.php method=post>"; echo "<tr>"; echo "<td>" . "<input type=text name=topic value=" . $record['Topic'] . "> </td>"; echo "<td>" . "<input type=text name=name value=" . $record['Name'] . "> </td>"; echo "<td>" . "<input type=text name=attendance value=" . $record['Attendance'] . "> </td>"; echo "<td>" . "<input type=hidden name=hidden value=" . $record['Topic'] . "> </td>"; echo "<td>" . "<input type=submit name=submit value=update" . "> </td>"; echo "</form>"; } echo"</table>"; mysqli_close($con); ?> </body> </html>
  12. Hi All, I'm looking to update a mysql column weekly, where by 5 randomly selected rows are given a new random number, from between 1 and the num_rows / 5. This cycle is looped again until all the entries have a new random group for the week. It is to help mix up the players for teams for 5 aside. It needs to be able to accomodate the posibillity of the num_rows not dividing exactly by 5, using ceil perhaps? As an example Name Group a 1 b 2 c 1 d 1 e 1 f 3 g 2 h 1 i 2 j 2 k 2 Then Next week Name Group a 2 b 1 c 2 d 2 e 1 f 2 g 3 h 1 i 2 j 1 k 1 I hope that makes sense. It'll be automated via cron job. I've been really struggling with it, this is as far as I have got. $totalgroupsraw = $num_rows /5; $totalgroups = ceil ($totalgroupsraw); $i = 1; while ($i<$totalgroups) { $pie = mysql_query("UPDATE table SET columnname=5 order by rand() LIMIT 5"); $i++; }; But as you will no doubt be able to see, this doesn't work well at all. I think I am close, but I just can't seem to sort out a good way to do it. Any help much appreciated. Thanks, Matt
  13. php 5.5.42 Database name: forums Table name: phpbb_users Row name: user_id What SQL query can I run in phpMyAdmin to update the user_id in every row, adding 8447002 to each user_id?
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.