Jump to content

Search the Community

Showing results for tags 'update'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • 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 (PhpStorm, VS Code, 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

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. I can not update the table like i want, when i want to change one row everything changes when i click update ! so what i want is when i click update to change only the row i want and not all the rows. Thanks for any help. <?php $con = mysql_connect("localhost","root",""); if (!$con){ die("Can not connect: " . mysql_error()); } mysql_select_db("food",$con); if(isset($_POST['update'])){ $UpdateQuery = " UPDATE producten SET Product='$_POST[product]', Item='$_POST[item]', Description='$_POST[description]', Extra='$_POST[extra]', Valuta='$_POST[valuta]', Price='$_POST[price]', Nummer='$_POST[nummer]' WHERE Product='$_POST[hidden]'"; mysql_query($UpdateQuery, $con); }; if(isset($_POST['delete'])){ $DeleteQuery = "DELETE FROM producten WHERE Product='$_POST[hidden]'"; mysql_query($DeleteQuery, $con); }; if(isset($_POST['add'])){ $AddQuery = "INSERT INTO producten (Product, Item, Description, Extra, Valuta, Price, Nummer) VALUES ('$_POST[uproduct]','$_POST[uitem]','$_POST[udescription]','$_POST[uextra]','$_POST[uvaluta]','$_POST[uprice]','$_POST[unummer]')"; mysql_query($AddQuery, $con); }; $sql = "SELECT * FROM producten"; $myData = mysql_query($sql,$con); echo "<table border=1> <tr> <th>Product</th> <th>Item</th> <th>Description</th> <th>Extra</th> <th>Valuta</th> <th>Price</th> <th>Nummer</th> </tr>"; while($record = mysql_fetch_array($myData)){ echo "<form action=mydata6.php method=post>"; echo "<tr>"; echo "<td>" . "<input type=text name=product value=" . $record['Product'] . " </td>"; echo "<td>" . "<input type=text name=item value=" . $record['Item'] . " </td>"; echo "<td>" . "<input type=text name=description value=" . $record['Description'] . " </td>"; echo "<td>" . "<input type=text name=extra value=" . $record['Extra'] . " </td>"; echo "<td>" . "<input type=text name=valuta value=" . $record['Valuta'] . " </td>"; echo "<td>" . "<input type=text name=price value=" . $record['Price'] . " </td>"; echo "<td>" . "<input type=text name=nummer value=" . $record['Nummer'] . " </td>"; echo "<td>" . "<input type=hidden name=hidden value=" . $record['Product'] . " </td>"; echo "<td>" . "<input type=submit name=update value=update" . " </td>"; echo "<td>" . "<input type=submit name=delete value=delete" . " </td>"; echo "</tr>"; echo "</form>"; } echo "<form action=mydata6.php method=post>"; echo "<tr>"; echo "<td><input type=text name=uproduct></td>"; echo "<td><input type=text name=uitem></td>"; echo "<td><input type=text name=udescription></td>"; echo "<td><input type=text name=uextra></td>"; echo "<td><input type=text name=uvaluta></td>"; echo "<td><input type=text name=uprice></td>"; echo "<td><input type=text name=unummer></td>"; echo "<td>" . "<input type=submit name=add value=add" . " </td>"; echo "</form>"; echo "</table>"; mysql_close($con); ?>
  2. Table: cquestions -> cqid, cqtext, showdate. I want to update 'showdate' field to tomorrows date.. cqid cqtext showdate 200 q1 2013-05-22 201 q2 0000-00-00 202 q3 0000-00-00 the idea is to display only one question everyday. showdate is compared with the current date and display the first question q1. the starting date only store in db. now i want to update only the next row (q2)'s showdate to tomorrows date. next day wen q2 is displayed q3 will be updated to tomorrows date. today q1 displayed. db is like this. cqid cqtext showdate 200 q1 2013-05-22 201 q2 2013-05-23 202 q3 0000-00-00 tomorrow q2 displayed. then db cqid cqtext showdate 200 q1 2013-05-22 201 q2 2013-05-23 202 q3 2013-05-24 203 q4 0000-00-00 my code: $today=date("Y/m/d"); $tomorrow= date("Y-m-d", strtotime("tomorrow")); echo "<form method='post' id='submit' action='checkresult.php'>"; $sql="SELECT * FROM cquestions where showdate= '$today' limit 1"; $result=mysql_query($sql); while ($row = mysql_fetch_array($result)) { $cqid=mysql_result($result,"cqid"); $update1="update cquestions set showdate='$tomorrow' where showdate='0000-00-00' and cqid!='$cqid' order by cqid limit 1"; mysql_query($update1); echo "<p>" . $row['cqtext'] . "</p>"; $sql2="SELECT * FROM canswers where cqid=".$row['cqid']; $result2=mysql_query($sql2); while($row2=mysql_fetch_assoc($result2)){ echo "<input type='radio' name='".$row['cqid']."' value='".$row2['cqans']."' />".$row2['aatext']; } /*echo "<input type='hidden' name='email' value='email' />";*/ } echo"<input type='submit' id='submit' name='submit' value='Submit Answers' />"; echo "</form>"; ?> this code update the next row, but the problem is its executed every time page loads and update the next row... i want to execute the update query only once for the day. how to do it?
  3. Hey guys! First time post here and I am only a begginer in programming. Anyway I have a few questions as I am stuck and have been for quite a while. I know this is a long post but it will cover the whole entire process of what I am doing at the moment. I really appreciate the time anyone can give me and will be happy to paypal someone over some $ for any help they can give me. Firstly, I am working with a bit of javascript and PHP. I am using a javascript method to update content from my table data in mysql without reloading the page. It works very well but I want to simplify the way i do things with the javascript so I am not left with repetative lines of code. Here is my javascript: $(document).ready(function() { //Edit link action (1) $('.edit_link').click(function(){$('.text_wrapper').hide(); var data=$('.text_wrapper').html(); $('.edit').show();$('.editbox').html(data);$('.editbox').focus();}); //Edit link action (2) $('.edit_link2').click(function(){$('.text_wrapper2').hide(); var data=$('.text_wrapper2').html();$('.edit2').show(); $('.editbox2').html(data);$('.editbox2').focus();}); //Mouseup textarea false (1) $(".editbox").mouseup(function(){return false}); //Mouseup textarea false (2) $(".editbox2").mouseup(function(){return false}); //Textarea content editing (1) $(".editbox").change(function(){$('.edit').hide();var boxval = $(".editbox").val(); var dataString = 'data='+ boxval;$.ajax({type: "POST",url: "update.php",data: dataString,cache: false,success: function(html){$('.text_wrapper').html(boxval);$('.text_wrapper').show();}});}); //Textarea content editing (2) $(".editbox2").change(function(){$('.edit2').hide(); var boxval = $(".editbox2").val();var dataString = 'data2='+ boxval;$.ajax({type: "POST",url: "update.php",data: dataString,cache: false,success: function(html){$('.text_wrapper2').html(boxval);$('.text_wrapper2').show();}});}); //Textarea without editing (1) $(document).mouseup(function(){$('.edit').hide();$('.text_wrapper').show();}); //Textarea without editing (2) $(document).mouseup(function(){$('.edit2').hide();$('.text_wrapper2').show();}); }); As you can see I am having to repeat the functions and all I do is change the name. Instead of repeating the script like I am over and over again to recognise different textareas is there a way I can array it or something like this so I don't have endless lines of the same code over and over again? I have allot more then just 2 textareas but of course shortened it for this post. Here is how I UPDATE the data in MySQL. I am looking into moving this over to PDO as I have be learning that PDO is the more safe and finctional option. My question here would be is there a simple way to UPDATE the rows instead of the way I doing this by repeating this process over and over again? I know I can use the: if (isset()); but I am troubled to work out how I would define the "id" of the data I am changing? <?php include("connection.php"); if($_POST['data']) { $data=$_POST['data']; $data = mysql_escape_String($data); $sql = "update slider set content='$data' where id='1'"; mysql_query( $sql); } if($_POST['data2']) { $data2=$_POST['data2']; $data2 = mysql_escape_String($data2); $sql = "update slider set content='$data2' where id='2'"; mysql_query( $sql); } ?> The HTML is quite simple. The form is wrapped in a div and the "edit" link is defined by class which again I repeat by just copy and past, the select is done via "id" which I need to define in the UPDATE section: <a href="#" class="edit_link" title="Edit">Edit</a> <? $sql=mysql_query("select content from slider where id='1'"); $row=mysql_fetch_array($sql); $profile=$row['content']; ?> <div class="text_wrapper" style=""><?php echo $profile; ?></div> <div class="edit" style="display:none"> <textarea class="editbox" cols="23" rows="3" name="profile_box"></textarea> </div> <a href="#" class="edit_link2" title="Edit">Edit</a> <? $sql=mysql_query("select content from slider where id='2'"); $row=mysql_fetch_array($sql); $profile=$row['content']; ?> <div class="text_wrapper2" style=""><?php echo $profile; ?></div> <div class="edit2" style="display:none"> <textarea class="editbox2" cols="23" rows="3" name="profile_box"></textarea> </div> I hate asking for help but I really need some guidence here as myself and Javascript are not good friends and myself and PHP are just starting a relationship, if you know what I mean. Any examples of how to achieve this? I do beleive if anyone could put me in the right direction it would be a great script to share around as it is very functional. I apologize for such a large post, however I really am stuck and have gone this far. I have researched google but find i just keep getting stuck. Idealy I just want to simplify the whole script, make it more functional and save myself the repetative task of going over the same thing again and again.
  4. i'm trying to add data into specific user in database. the one who login in the form is admin and the admin will add information to the user's database.. here's the php code <?php session_start(); if ($_SESSION['UserId'] == "") { echo "Please Login first"; } else { echo "<h1> Appliances's adding list</h1>"; echo "<table>"; echo "<form action ='addappliancesprocess.php' method = 'POST'>"; echo "<tr> <td>Appliances Name: <input type='text' name='appliancesname'></td> </tr>"; echo "<tr> <td>Port Number: <select name = 'port' value='port'> <option value 'RB0'>RB0</option> <option value 'RB1'>RB1</option> <option value 'RB2'>RB2</option> <option value 'RB3'>RB3</option> <option value 'RB4'>RB4</option> <option value 'RB5'>RB5</option> <option value 'RB6'>RB6</option> <option value 'RB7'>RB7</option> </select> </tr>"; echo "<tr> <td>Insert characters on: <input type='text' name='charon'></td> </tr>"; echo "<tr> <td>Insert characters off: <input type='text' name='charoff'></td> </tr>"; echo "<tr> <td colspan=2 align= 'right'><br> <INPUT Type='button' VALUE='Back' onClick='history.go(- 1);return true;'> <input type='submit' name='update' value='Submit'> </td> </tr>"; echo "</table>"; } ?> and here is the process <?php session_start(); $appliancesname=$_POST['appliancesname']; $port=$_POST['port']; $username=$_REQUEST['username']; $charon=$_POST['charon']; $charoff=$_POST['charoff']; $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("myfyp", $con); ?> <?php $query="SELECT from user where UserId = '".$_SESSION ['UserId']."'"; //if ($username != UserId) { //echo "no user"; //}else{ $sql="INSERT INTO appliances VALUES ('','$appliancesname','$port','$username','','$charon','$charoff')"; echo $query; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "You have choose the following:<br>"; echo "<br>Appliances: $appliancesname</br>"; echo "<br>Port Number: $port</br>"; echo "<br>Character on: $charon</br>"; echo "<br>Character off: $charoff</br>"; echo "<br><INPUT Type='button' VALUE='Back' onClick='history.go(- 1);return true;'>"; //} ?> when i try to add it will add to the database but the port is not updated and the userid is empty.. i'm sorry.. i am new to php.. there are lots that i don't know..
  5. Hello, I'm trying to display the results of my query in a text box so that they can be edited, if need be, and updated in the database. I'm getting the error below, with the code below. I've tried a couple of different ways to format the "value" of the text box as you can see by the second one that's commented out and still a no go. Thanks for any help in advance guys. The error below is referring to the code just below here. echo "<td><input type="text" name="firstname" value="$firstname"></td>"; Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\ $rs=odbc_exec($conn,$sql); if (!$rs) {exit("Error in SQL");} echo "<table><tr>"; echo "<th>First Name</th>"; echo "<th>Middle Initial</th>"; echo "<th>Last Name</th>"; echo "<th>Full Name</th>"; echo "<th>Provider ID</th></tr>"; while (odbc_fetch_row($rs)) { $firstname=odbc_result($rs,"provider_first_name"); $middleinitial=odbc_result($rs,"provider_middle_name"); $lastname=odbc_result($rs,"provider_last_name"); $fullname=odbc_result($rs,"provider_full_name"); $provider_id=odbc_result($rs,"provider_id"); echo "<tr><td>$firstname</td>"; echo "<td><input type="text" name="firstname" value="$firstname"></td>"; echo "<td>$middleinitial</td>"; echo "<td>$lastname</td>"; echo "<td>$fullname</td>"; echo "<td>$provider_id</td>"; // echo "<td><input type="text" name="textfield" value='".$providerid."'"></td>"; echo "<td>$providerid</td></tr>"; } odbc_close($conn);
  6. im trying to make a script where the user can update there details, (in this case the email) but when the script is running it comes up sucess to say its worked and updated. however when i open up my database in notepad or sql workbench the email has not changed its still the same. any ideas what it could be? or maybe im reading my database info wrong? CODE: <?php session_start(); $user_name = "root"; $password = ""; $database = "fixandrun"; $server = "localhost"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); $currentemail = $_POST['currentemail']; $newemail = $_POST['newemail']; $confirmnew = $_POST['confirmemail']; $user = $_SESSION["username"]; if ($db_found) { $dbemail =mysql_query("SELECT email FROM staff WHERE username= '$user'"); //echo "$currentemail"; //echo "$newemail"; //echo "$confirmnew"; //echo "$dbemail"; if($currentemail == $dbemail || $newemail == $confirmnew) { $query = "UPDATE staff SET email = '$confirmnew' WHERE username = '$user'"; if(mysql_query($query)){ echo "updated";} else{ echo "fail";} } else { echo" some of your details are incorrect please try again. check that your current email is entered correctly and the new email matches."; } } else { print "Database NOT Found."; mysql_close($db_handle); } ?>
  7. Noob here learning PHP with a MySQL database. I know that this isn't the best way to connect to a database and I should probably be using variables as well as stored procedures. I just want to make this functional then I will go back and learn how to make it more secure. I've put a database together with 5 fields, id, author, title, date, body. id is the primary key set as autoincrement. Currently I have a page that displays each row in the database and has an option at the bottom to add a new entry. I want to add the option to edit a current entry. I've spent the last 2 hours doing trial/error and reading forums and I don't really feel like I've made any headway. My Main page <?php $con = mysql_connect("XXXXX","XXXXX","XXXXX"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("XXXXX", $con); $result = mysql_query("SELECT * FROM news"); echo "<table border='1'> <tr> <th>ID</th> <th>Author</th> <th>Title</th> <th>Date</th> <th>Body</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['id'] . "</td>"; echo "<td>" . $row['author'] . "</td>"; echo "<td>" . $row['title'] . "</td>"; echo "<td>" . $row['date'] . "</td>"; echo "<td>" . $row['body'] . "</td>"; echo "<td><a href='file133.php?id=" . $row['id'] . "'>edit</a></td>"; echo "</tr>"; } echo "</table>"; echo "<form action='file132.php' method='post'> <table> <tr><td>Author:</td><td> <input type='text' name='author'></td></tr> <tr><td>Title:</td><td> <input type='text' name='title'></td></tr> <tr><td>Body:</td><td> <input type='text' name='body' size='75'></td></tr> <tr><td></td><td><input type='submit' value='Submit'></td></tr> </table> </form>"; mysql_close($con); ?> Clicking Edit takes you to this page where you can enter in the new data <?php $con = mysql_connect("XXXXX","XXXXX","XXXXX"); if (!$con) { die('Could not connect: ' . mysql_error()); } if (isset($_GET['id']) AND $_GET['id'] > 0) { mysql_select_db("XXXXX", $con); echo "<form action='file134.php' method='post'> <table> <tr><td>Author:</td><td> <input type='text' name='author'></td></tr> <tr><td>Title:</td><td> <input type='text' name='title'></td></tr> <tr><td>Body:</td><td> <input type='text' name='body' size='75'></td></tr> <tr><td></td><td><input type='submit' value='Submit'></td></tr> </table> </form>"; } mysql_close($con); ?> When you click submit it goes to this page. I know this code below is all wrong because it just displays the actual code from the 0) to the end. I just need some direction on how to make this functional. <?php $con = mysql_connect("XXXXX","XXXXX","XXXXX"); if (!$con) { die('Could not connect: ' . mysql_error()); } if (isset($_GET['id']) AND $_GET['id'] > 0) { mysql_select_db("XXXXX", $con); $mysql_query = "UPDATE news SET Author = '$_POST[author]', title = '$_POST[title]', date = NOW(),body = '$_POST[body]' WHERE id= $row['id'] "; } if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Record updated, click <a href='file130.php'>here</a> to return to the list of records."; mysql_close($con); ?>
  8. Hiya i'm working on a project, which involves a list of checkboxes which are automaticly populated by the database which is currently working at while ($row = mysql_fetch_array($sql)) { $id = $row['id']; $hotbox = $row['hot_job']; ?> <form name='hotbox' action='hot_update.php' method='POST'> <tr><td><strong><?php echo $id; ?></strong></td> <td><input name="ONOFF<? echo $row['id']; ?>" type="checkbox" id="ONOFF" value="1" <?php if ($row['hot_job'] == 'YES') { echo "checked";} else {} ?> </td></tr> <?php } ?> however when the user has unchecked/checked the correct boxes and clickes update, nothing changes. Here is my current code foreach($_POST['id'] as $id) { $onoff = 0; if (isset($_POST["ONOFF".$id])) { $onoff = 1; } if($onoff == 1) { $sql1="UPDATE jobs SET hot_job='".$onoff."' WHERE id='".$id."'"; } else { $sql1="UPDATE jobs SET hot_job='".$onoff."' WHERE id='".$id."'"; } echo $id; echo $onoff; $result1=mysql_query($sql1); } ?> The mysql setup is id hot_job 1 YES 2 YES 3 NO 4 YES ect Any help would be greatly appreciated
  9. I have a data base that updates the photo 1) A error occurs everytime i update the database error:- Error in Query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\0JFIF\0\0`\0`\0\0ÿÛ\0C\0 ' at line 3 code:- $sql = "UPDATE freelancer SET image=$imgData, name='{$_FILES['image']['name']} WHERE id=$in"; here $imgData is image with slashes 2) this is the error for Error in Query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''image-04.jpg WHERE id=29' at line 3 code:- $sql = "UPDATE freelancer SET image='$imgData', name='{$_FILES['image']['name']} WHERE id=$in"; please help for the error
  10. Hi guys, Say I got two tables, Table1 - columns A, B, C, flag - approx 200 000 rows Table2 - columns A, B, C - approx 20 000 rows What I want to do is: Update Table1 Set flag = 1 Where "at least one row from Table2 has the same entries in columns A, B and C" Right now I am solving this with a "select distinct A, B, C from Table2" and transform this into a long where condition (with php). afterwards I apply the above update with this where condition. However this aproche needs about 5 minutes to run and I believe this could be much faster when I just know the right MySql command for this. Can anyone help me? cheers, Peter
  11. My code is working (ie updating the database) on my local site using MAMP however, it is not updating in my remote site. Can anyone understand why? I have copied my local files up to my remote and have not changed anything. The code runs through the mysql query and display the error message. The code starts going through the loop then stops at the end of the first record in the recordset and spits out the error message. I don't understand why it works okay on local and not on remote. Would it be something on the remote server side? Please help urgently. Thanks. Regards. cracker1 <?php $size = count($_POST['OrderNumber']); $i = 0; while ($i < $size) { $OrderNumber= $_POST['OrderNumber'][$i]; $OrderDate= $_POST['OrderDate'][$i]; $RequiredDate= $_POST['RequiredDate'][$i]; $fk_TrophyCode= $_POST['fk_TrophyCode'][$i]; $Customer= $_POST['Customer'][$i]; $PartCode= $_POST['PartCode'][$i]; $PartDescription= $_POST['PartDescription'][$i]; $PartQty= $_POST['PartQty'][$i]; $Freight= $_POST['Freight'][$i]; $Supplier= $_POST['Supplier'][$i]; $OrderDetailID = $_POST['OrderDetailID'][$i]; $query = "UPDATE tbl_OrderDetails SET OrderNumber = '$OrderNumber', OrderDate = '$OrderDate', RequiredDate = '$RequiredDate', fk_TrophyCode = '$fk_TrophyCode', Customer = '$Customer', PartCode = '$PartCode', PartDescription = '$PartDescription', PartQty = '$PartQty', Freight = '$Freight', Supplier = '$Supplier' WHERE OrderDetailID = '$OrderDetailID'"; mysql_query($query) or die ("Error in update query: $query"); ++$i; } ?>
  12. I have a problem when i Click the Edit button int he form, the database doesn't update, In the beginning i thought i had a problem with the query, but I did a check as a query and everything was fine. Can someone suggest something please. //this is the file - album.func.php function edit_album($album_id, $album_name, $album_description) { $album_id = ((int)$album_id); $album_name = mysql_real_escape_string($album_name); $album_description = mysql_real_escape_string($album_description); mysql_query("UPDATE `albums` SET `name`='$album_name', `description`='$album_description' WHERE `album_id`='$album_id' AND `user_id`=".$_SESSION["user_id"]); } //this is the file - edit_album.php if (!empty($errors)) { foreach ($errors as $error) echo $error; }else { edit_album($album_id, $album_name, $album_description); header('Location: index.php'); exit(); }} ?> <?php $album_id = $_GET["album_id"]; $album_data = album_data($album_id, 'name', 'description'); ?> //this is the form <form action="?album_id=<?php echo $album_id; ?>" method="post"> <p>Name:</br><input type="text" name="album_name" maxlength="55" value="<?php echo $album_data["name"]; ?>"/></p> <p>Description:</br><textarea name="album_description" rows="6" cols="35" maxlength="500"><?php echo $album_data["description"]; ?>
  13. My plugin is a custom export/update plugin that lets the user export his products, update the price grids, and upload the csv to change the data quicker than using the visual editor. The price grids are stored as a serialized array in the post's meta (_cp_array). To test my plugin, I uploaded a csv with data identical to that which was already in the DB. The function below informed that the Table Rates had not changed (because they hadn't!). Next, I changed ONE value in ONE row of the csv. Tested again. This time, the function informed that for the product I changed, the post meta had been updated. However, the meta is never actually updated. Looking in the DB for the meta (_cp_array), the serialized string stays the same after running my upload function multiple times, with update_post_meta returning true each time, and echoing the "updated" message. For debugging purposes, I used var_export($unserialized) to see what it outputted, and also var_export(serialize($unserialized)) to see what the data should look like when writing the serialized array/string to the DB. The var_export (serialized and not) on my plugin screen always displays the new, changed data from the csv. It gets even stranger...next I tried adding new metadata to a product that didn't have anything for that specific metadata (it was empty and the meta key didn't exist for that product). The function displays that it updated the metadata for that product. However, looking in the DB reveals that the serialized value for that product's meta (_cp_array) was very different from the data I entered! The var_export displays the correct array and serialized string, but the DB had very different keys and values! All relevant examples/info: http://pastebin.com/jYjuzg6G Why is the plugin not changing the metadata, even though the function returns true? And why, when it added new metadata, did it add incorrect metadata, even though the serialized array was correct when outputted to the screen? The below code is responsible for updating the product's _cp_array: if(update_post_meta($id, '_cp_array', $unserialized)) echo 'Table Rate Prices Updated.<br />'; else echo 'No Table Rate Change.'; var_export($unserialized); echo '<br />'; var_export(serialize($unserialized));
  14. I would like to update a table or insert if a specific combination of indices do not already exist. The table is very simple. CREATE TABLE `sessProdLnk` ( `products_id` varchar(20) NOT NULL, `sessions_id` varchar(255) NOT NULL, `qty` int(6) NOT NULL, KEY `products_id` (`products_id`), KEY `sessions_id` (`sessions_id`) ENGINE=MyISAM DEFAULT CHARSET=latin1 So, I would like to search for a match between my data, and any row in sessProdLnk where both the sessions_id and products_id match. Then I would like to update any entries in qty where they match, and insert a new row for any data pairs that do not have matches. I know some of this comparison may have to be done programmatically in the php script, but I am still getting to know MYSQL and was wondering how much of the work it will do for me given these parameters.
  15. I have an html form that takes a date and send it to an php script: <form action='tupdatecompletiondate.php' method='post'><input type='hidden' name='idtosubmit' value=$id><tr> <td><label>Date:</label></td> <td><input type= 'date' name= 'date' value='Select Date' id='popupDatepicker'></td> </tr><input type='submit' value='Click to Update'></form> I've got it going to this script: $id = $_POST['idtosubmit']; $date = $_POST['date']; $datetoset = date('Y-m-d', strtotime($date)); $sql = "UPDATE needs SET completiondate=$datetoset WHERE ID=$id"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } mysql_close(); Confused as to why it's not working. It takes the date, sends it to the php script, makes it into a format that is accepted by the DATE column, and then puts it in that column....well at least its supposed to.
×
×
  • 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.