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. hi, I tried to change update query from mysql to mysqli, at first under mysql is works great to update into mysql database but when i changed to mysqli is not doing update it. can anyone tell me what did i missed! under mysql <?php include('db.php'); if(isset($_GET['status'])) { $status1=$_GET['status']; $select=mysql_query("select * from manage where id='$status1'"); while($row=mysql_fetch_object($select)) { $status_var=$row->status; if($status_var=='0') { $status_state=1; } else { $status_state=0; } $update=mysql_query("update manage set status='$status_state' where id='$status1' "); if($update) { header("Location:index.php"); } else { echo mysql_error(); } } ?> <?php } ?> and under mysqli <?php include('db.php'); $dbcs = new mysqli($mysql_hostname, $mysql_user, $mysql_password, $mysql_database); if(isset($_GET['status'])) { $status1=$_GET['status']; $sql = "select * from product where product_id='$status1'"; $result=mysqli_query($dbcs,$sql); while($row=mysqli_fetch_object($result)) { $status_var=$row->status; if($status_var=='0') { $status_state=1; } else { $status_state=0; } $mysqli->query("UPDATE product set status='$status_state' where product_id='$status1' "); if($mysqli) { header("Location:item.php"); } else { echo mysqli_error(); } } ?> <?php } ?>
  2. Hi, I am having a bit of a problem with a simple task and I was wondering if someone would be able to help. I have a php system which allows members to sign up, stores their information in a mysql database, then they can sign in and do all sorts of things. The area I have a problem with is I'm trying to make an update page so that they can edit their details stored in the mysql database. My code is as follows. <?php session_start(); include_once "base.php"; //connects to database $username = mysql_real_escape_string($_SESSION['Username']); // get users username from session $forename = mysqL_real_escape_string($_SESSION['Forename']; //gets already stored forename $newforename = mysql_real_escape_string($_POST['newforename']);//post for new forename $registerquery = mysql_query("INSERT INTO users WHERE Username = '".$username."'(Forename) VALUES('".$newforename."')"); //finds row for the user and updates the forename column with new record ?> <form method="post" action="index.php" name="registerform" id="registerform"> <fieldset> <label for="newforename">Forename:</label><input type="text" name="newforename" id="newforename" /><br /> <input type="submit" name="register" id="register" value="Register" /> </fieldset> </form> Unfortunately this code does not update the database at all, however it does not crash or produce any errors! I would really appreciate any help you can give with this.
  3. Hi again , Im trying to create form which allows the users to edit their data , I've created the form ,added the sql i think is right but its not working and giving me sql erro that the data can't be inserted . this is my code for the form details.php : <?php include '../header.php'; include '../config2.php'; session_start(); $id = $_POST['ID']; ?> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/parsley.js"></script> <script> $(document).ready(function() { // submit data on click and check if valid $('#sendData').click(function(e) { //check if valid with parsley var valid = $('#detailform').parsley ( 'validate' ); if ( valid === false ) { e.preventDefault(); } else { $.post("updateprocess.php", $("#detailform").serialize()); } }); }); </script> <div id="title"> <div class="inner"> <h1>Changing Your Account Details</h1> </div> </div> <div id="content" class="right-sidebar"> <div class="container inner"> <div id="main" role="main"> <div class="container"> <h3>Please Choose Which information Your would like to change</h3> <form data-validate="parsley" method="POST" action="updateprocess.php" id="detailform" > <label>Email Address</label> <input type="text" name="login_email" data-required="true" value="<?php echo $account['login_email']; ?>"/> <label>Change a password</label> <input type="password" name="login_password" data-notblank="true"/> <label>Re-enter new password</label> <input type="password" name="confirm" data-notblank="true"/> <label>First Name</label> <input type="text" name="first_name" data-required="true" value="<?php echo $account['first_name']; ?>" disabled="disabled" /> <label>Last Name</label> <input type="text" name="last_name" data-notblank="true" /> <label>Address line 1</label> <input type="text" name="address_one" data-required="true" value="<?php echo $account['address_one']; ?>"/> <label>Address line 2</label> <input type="text" name="address_two" data-required="true" value="<?php echo $account['address_two']; ?>"/> <label>Town/City</label> <input type="text" name="town_city" data-required="true" value="<?php echo $account['town_city']; ?>" /> <label>County</label> <input type="text" name="county_option" data-required="true" value="<?php echo $account['county_option']; ?>"/> <label>Postcode</label> <input type="text" name="post_code" data-required="true" value="<?php echo $account['post_code']; ?>"/> <label>Phone number</label> <input type="text" name="phone_number" data-required="true" value="<?php echo $account['phone_number']; ?>"/> <p></p> <p></p> <p></p> <p></p> <p></p> <input type="checkbox" class="checkbox" id="agree" name="agree" /> I Agree With Terms & Conditions</p> <td> <input type="submit" name="submit" class="button" value= "Save"/></td> </form> </div> <div class="space"></div> </div> <ul class="sidebar" role="complementary"> <li> <h2>Navigation</h2> <ul class="link-list"> <li><a href="/account/dashboard.php">Dashboard</a></li> <li><a href="/account/transfer.php">Transfer Money</a></li> <li><a href="/account/transactions.php">Transactions</a></li> <li><a href="/account/withdrawal.php">Withdraw Funds</a></li> <li><a href="/account/upload.php">Upload Funds</a></li> <li><a href="/account/details.php">Change My details</a></li> </ul> </li> </ul> </div> </div> <?php include '../footer.php'; ?> this is the update.php script <?php include "config2.php"; $id = $_POST['ID']; $sql="SELECT * FROM users WHERE id='$id'"; $result=mysql_query($sql); $id = $_POST['ID']; $rows=mysql_fetch_array($result); $email = $_POST['login_email']; $pass = md5($_POST['login_password']); $confirm = md5($_POST['confirm']); $fname = $_POST['first_name']; $lname = $_POST['last_name']; $addressone = $_POST['address_one']; $addresstwo = $_POST['address_two']; $towncity = $_POST['town_city']; $countyoption = $_POST['county_option']; $postcode = $_POST['post_code']; $phone = $_POST['phone_number']; $update = 'UPDATE users SET( login_email, login_password, confirm, first_name, last_name, address_one, address_two, town_city, county_option, post_code, phone_number) VALUES("'.$email.'","'.$pass.'","'.$confirm.'","'.$fname.'","'.$lname.'","'.$addressone.'","'.$addresstwo.'","'.$towncity.'","'.$countyoption.'","'.$postcode.'","'.$phone.'")WHERE id="'.$id.'""'; //$insert = 'UPDATE users SET login_email="'.$email.'", login_password="'.$pass.'", confirm="'.$confirm.'", first_name="'.$fname.'", last_name="'.$lname.'", address_one="'.$addressone.'", address_two="'.$addresstwo.'", town_city="'.$towncity.'", county_option="'.$countyoption.'", post_code="'.$postcode.'", phone_number="'.$phone.'" WHERE id="'.$id.'""'; mysql_query($update) or die("Failed Updating Your Data,check SQL"); header( 'Location: ../account/success.php' ) ; ?>
  4. I have a database class that uses PDO and it all works until i need to do an update where I increment the value What I have is a table and one of the columns is called 'counter' and I need to update this table every time a page is visited This is the function that handles all the PDO and creates the query /** * update * @param string $table A name of table to insert into * @param string $data An associative array * @param string $where the WHERE query part */ public function update($table, $data, $where) { ksort($data); $fieldDetails = NULL; foreach($data as $key=> $value) { $fieldDetails .= "`$key`=:$key,"; } $fieldDetails = rtrim($fieldDetails, ','); $sth = $this->prepare("UPDATE $table SET $fieldDetails WHERE $where"); foreach ($data as $key => $value) { $sth->bindValue(":$key", $value); } $sth->execute(); } and this is how I call the function by passing parametres to the function $board = ucwords(str_replace('-',' ',$board)); $sql = "SELECT boardid from boards WHERE boardname = :board"; $rows = $this->db->select($sql, array(':board' => $board)); $postData = array( 'counter' => 'counter+1', ); $this->db->update('topics', $postData, "`topicid` = {$topic} AND `boardid` = {$rows[0]['boardid']}"); It fails the update with this error message The counter column is of type INT
  5. I have a function that updates a database and it works fine for one record but i have a form which shows loads of rows with checkboxes and i want to do a batch update (I suppose the principle is the same for a batch delete). When I click a load of checkboxed and call the funtion to update, i get an error about an array to string conversion and also this error message "Unknown column 'Array' in 'where clause" I know a way around it but it's not great using a foreach loop to update the database but that involves loads of queries This is my function I call to update the database /** * update * @param string $table A name of table to insert into * @param string $data An associative array * @param string $where the WHERE query part */ public function update($table, $data, $where) { ksort($data); $fieldDetails = NULL; foreach($data as $key=> $value) { $fieldDetails .= "`$key`=:$key,"; } $fieldDetails = rtrim($fieldDetails, ','); $sth = $this->prepare("UPDATE $table SET $fieldDetails WHERE $where"); foreach ($data as $key => $value) { $sth->bindValue(":$key", $value); } $sth->execute(); } This works public function newsEdit($data) { $postData = array( 'title' => $data['news_title'], 'content' => $data['news_content'], 'photo' => $data['imgname'], 'keywords' => $data['news_keywords'], 'alternate' => $data['alternate'] ); $this->db->update('news', $postData, "`id` = {$data['newsid']}"); } $data = array(); $data['news_title'] = $_POST['news_title']; $data['news_content'] = $_POST['news_content']; $data['imgname'] = $_POST['imgname']; $data['news_keywords'] = $_POST['news_keywords']; $data['alternate'] = substr($_POST['imgname'],0,strrpos($_POST['imgname'], ".")); newsEdit($data); This doesn't public function newsArchive($ids) { $postData = array( 'archived' => 'Y' ); $this->db->update('news', $postData, "`id` IN ({$ids})"); } newsArchive($_POST['id']); What have i got to change to get the update working?
  6. hi ive been trying to sort this out all day, im very inexperianced in php but really want to do well in it and at the moment ive got a table working linked to a database and which pulls records but now i want to get an update and delete button but i cant seem to hack it heres the code. <?php $con = mysqli_connect("localhost","root","","lcm"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } //updates table. if (isset($_POST['update'])){; $UpdateQuery = "UPDATE tbl_contactinfo SET Name='$_POST[Name]', Address='$_POST[Address]' WHERE Name='$_POST[hidden]'"; mysql_query($UpdateQuery, $con); } if (isset($_POST['delete'])){; $DeleteQuery = "DELETE FROM tbl_contactinfo WHERE Name='$_POST[hidden]'"; mysql_query($DeleteQuery, $con); } //selects the table. $sql = "Select * from tbl_contactinfo"; if ($result = mysqli_query($con, $sql)) { echo "<table border='1'> <tr> <th>Name</th> <th>Address</th> </tr>"; while($row = mysqli_fetch_array($result)) { echo '<form action="index1.php" method="post">'; echo '<tr>'; echo '<td><input type="text" name="name" value="' . $row['Name'] . '" /></td>'; echo '<td><input type="text" name="address" value="' . $row['Address'] . '" /></td>'; echo '<td><input type="hidden" name="hidden" value="' . $row['ID'] . '" /></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 "</table>"; } ?> <html> <body> <form action="insert.php" method="post"> Name: <input type="text" name="Name"> Address: <input type="text" name="Address"> <input type="submit"> </form> </body> </html> and error messages ive been getting. ( ! ) Notice: Undefined index: Name in C:\wamp\www\Index1.php on line 12 Call Stack # Time Memory Function Location 1 0.0000 147208 {main}( ) ..\Index1.php:0 ( ! ) Notice: Undefined index: Address in C:\wamp\www\Index1.php on line 12 Call Stack # Time Memory Function Location 1 0.0000 147208 {main}( ) ..\Index1.php:0 ( ! ) Warning: mysql_query() expects parameter 2 to be resource, object given in C:\wamp\www\Index1.php on line 13 Call Stack # Time Memory Function Location 1 0.0000 147208 {main}( ) ..\Index1.php:0 2 0.1562 154608 mysql_query ( ) ..\Index1.php:13 these are for update and for delete ( ! ) Warning: mysql_query() expects parameter 2 to be resource, object given in C:\wamp\www\Index1.php on line 18 Call Stack # Time Memory Function Location 1 0.0000 147208 {main}( ) ..\Index1.php:0 2 0.1406 154456 mysql_query ( ) ..\Index1.php:18 ive stoped the error messages before dont no how i did it but they wernt showing, only problem is when i pressed them nothing happened any help will be great.
  7. hi ive been trying to sort this update button out but i keep getting errors and got no clue how to fix it. heres the code. <?php $con=mysqli_connect("localhost","","","lcm"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql = "Select * from tbl_contactinfo"; if (isset($_POST['update'])){ $UpdateQuery = "UPDATE tbl_contactinfo SET Name='$_POST[Name]', Address='$_POST[Address]' WHERE Name = '$_post[hidden]'"; mysql_query($UpdateQuery,$con); }; if ($result = mysqli_query($con, $sql)){ echo "<table border='1'> <tr> <th>Name</th> <th>Address</th> </tr>"; while($row = mysqli_fetch_array($result)) { echo "<form action = index1.php method =post>"; echo "<tr>"; echo "<td>" . "<input type= text name =Name value =" . $record['Name'] . "</td>"; echo "<td>" . "<input type= text name =address value =" . $record['Address'] . "</td>"; echo "<td>" . "<input type= hidden hidden =Name value =" . $record['hidden'] . "</td>"; echo "<td>" . "<input type= submit name = update value=update". " </td>"; echo "</form>"; } echo "</table>"; mysql_close($con); ?> if someone could help id really apreciate it.
  8. Hi I am trying to create a button so the user can update points. I have a button so that it displays what is in the data base but I want another button to update the database. Here is the script for the button <?php //create_cat.php include 'connect.php'; include 'header.php'; include 'timeout.php'; echo '<h2>Review Member Rewards</h2>'; if($_SESSION['signed_in'] == false | $_SESSION['user_level'] != 1 ) { //the user is not an admin echo 'Sorry, you do not have sufficient rights to access this page.'; } else { $sql = "select member, cat_name from rewards, users where member = user_name"; $result = mysql_query($sql); if(!$result) { //the query failed, uh-oh :-( echo 'Error while selecting from database. Please try again later.'; } else { $dropdown = "<select name='mem'>"; $catdropdown = "<select name='catdp'>"; while($row = mysql_fetch_assoc($result)) { $dropdown .= "\r\n<option value='{$row['member']}'>{$row['member']}</option>"; $catdropdown .="\r\n<option value = '{$row['cat_name']} '>{$row['cat_name']}</option>"; } $dropdown .= "\r\n</select>"; $catdropdown .="\r\n</select>"; echo ' <form action="" method="post">' . $dropdown.' '. $catdropdown. ' <input type="text" name="max_point_cont" value="" /> <input type="text" name="points_earn_cont" value="" /> <input type="submit" value="Get Results">; <input type="submit" name="update" value="Update Rewards" onclick="action='updaterew.php'">; </form>'; } // only qeury the rewards table when the form above has been submitted if(isset($_POST['mem'])) { $post_sql = "select member, cat_name, point_earn, max_point from rewards where member = '" . mysql_real_escape_string($_POST['mem']) . "' and cat_name = '". mysql_real_escape_string($_POST['catdp']) . "'" ; $result_post = mysql_query($post_sql); if(!$result_post) { //the query failed, uh-oh :-( echo 'Error while selecting rewards from database. Please try again later.'; } else { echo '<table border="1"> <tr> <th>Member</th> <th>Category</th> <th>Points Earned</th> <th>Max Points</th> </tr>'; while($row = mysql_fetch_assoc($result_post)) { echo '<tr>'; echo '<td>' . $row['member'] . '</td>'; echo '<td>' . $row['cat_name'] . '</td>'; echo '<td>'. $row['point_earn']. '</td>'; echo '<td>' . $row['max_point']. '</td>'; echo '</tr>'; } echo '</table>'; } } } ?> Then here is the update query. <!DOCTYPE html> <?php //create_cat.php include 'connect.php'; include 'header.php'; include 'timeout.php'; if($_SERVER['REQUEST_METHOD'] != 'POST') { //someone is calling the file directly, which we don't want echo 'This file cannot be called directly.'; } else { //check for sign in status if(!$_SESSION['signed_in']) { echo 'You must be signed in to post a reply.'; } else { //a real user posted a real reply $sql = "UPDATE `rewards` SET `max_point`= `max_point`+ '" . $_POST['max_point_cont'] . "',`point_earn`= `point_earn` + '" . $_POST['points_earn_cont'] . "' WHERE member = '" . mysql_real_escape_string($_POST['mem']) . "' and cat_name = '". mysql_real_escape_string($_POST['catdp']) . "'" ; $result = mysql_query($sql); if(!$result) { echo 'Your reply has not been saved, please try again later.'; } else { echo 'Your rewards have been updated.' } } include 'footer.php'; ?>
  9. I'm having issues converting to MySQLI, can someone take a look for me. Thanks, salestatusupdateplusone.php
  10. Hi I am having a little problem trying to figure out how to create two text boxes on this form so the user can add values to the max points or points earned. Then I would like once the update happens that it shows the new values from the database. The update query is based on the Member and Category. I was thinking about adding two text boxes in the form where the dropdown is but I am not sure how I would reference those boxes in my update query. <?php //create_cat.php include 'connect.php'; include 'header.php'; include 'timeout.php'; echo '<h2>Review Member Rewards</h2>'; if($_SESSION['signed_in'] == false | $_SESSION['user_level'] != 1 ) { //the user is not an admin echo 'Sorry, you do not have sufficient rights to access this page.'; } else { $sql = "Select user_name from users"; $result = mysql_query($sql); if(!$result) { //the query failed, uh-oh :-( echo 'Error while selecting from database. Please try again later.'; } else { $dropdown = "<select name='mem'>"; while($row = mysql_fetch_assoc($result)) { $dropdown .= "\r\n<option value='{$row['user_name']}'>{$row['user_name']}</option>"; } $dropdown .= "\r\n</select>"; echo ' <form action="" method="post">' . $dropdown . ' <textpoint name="max_point_cont"></textpoint><br /><br /> <textpoint name="points_earn_cont"></textpoint><br /><br /> <input type="submit" value="Get Results"> </form>'; } // only qeury the rewards table when the form above has been submitted if(isset($_POST['mem'])) { $post_sql = "select member, cat_name, point_earn, max_point from rewards where member = '" . mysql_real_escape_string($_POST['mem']) . "'"; $result_post = mysql_query($post_sql); if(!$result_post) { //the query failed, uh-oh :-( echo 'Error while selecting rewards from database. Please try again later.'; } else { echo '<table border="1"> <tr> <th>Member</th> <th>Category</th> <th>Points Earned</th> <th>Max Points</th> </tr>'; while($row = mysql_fetch_assoc($result_post)) { echo '<tr>'; echo '<td>' . $row['member'] . '</td>'; echo '<td>' . $row['cat_name'] . '</td>'; echo '<td>'. $row['point_earn']. '</td>'; echo '<td>' . $row['max_point']. '</td>'; echo '</tr>'; } echo '</table>'; } } }
  11. Hi, I'm having difficulty with some PHP coding I have put together. I have a HTML search form that allows users to search a MySQL DB for a value and posts the value to a PHP page, this then displays the results. This part of my code is working. My problem is the second half of what I want to do. I have added a submit button for each record that is displayed so that if the user selects that result it increments a value in the row to show how many times it has been selected. At the minute it always updates the last record rather than the one selected, I can't work out why this is as I have set the update query to update when equal to the id of that row. A second issue is that after clicking submit the page then displays all records from the database rather than those previously displayed after the initial search. If anyone could point out where I'm going wrong I'd appreciate it. Thanks, here is my code; <?php mysql_connect ("localhost", "USERNAME","PASSWORD") or die (mysql_error()); mysql_select_db ("DBNAME"); $term = $_POST['term']; $sql = mysql_query("select * from TABLE where point like '%$term%' or point2 like '%$term%' or point3 like '%$term%' "); echo "here are your results for"; echo "<br>"; echo "search criteria: "; echo $term; echo "<br>"; echo " "; while ($row = mysql_fetch_array($sql)){ $chosen = $row['choice']; $id = $row['id']; echo '<form name="form1" id="form1" method="POST" action="">'; echo "<table>"; echo "<tr>"; echo '<td> 1 </td>'; echo '<td> 2 </td>'; echo '<td> 3 </td>'; echo '<td> 4 </td>'; echo '<td> 5 </td>'; echo '<td> 6 </td>'; echo "<tr>"; echo "<td>" .$row['field1']."</td>"; echo "<td>" .$row['field2']."</td>"; echo "<td>" .$row['field3']."</td>"; echo "<td>" .$row['field4']."</td>"; echo "<td>" .$row['field5']."</td>"; echo "<td>" .$row['id']."</td>"; echo "<tr>"; echo '<td colspan="6"> <input type = "submit" id="submit" name="submit" value="submit"> </td>'; echo "</table>"; echo "</form>"; echo "<br>"; } if (isset($_POST['submit'])) { $likes = $liked+1; $insert= mysql_query("UPDATE Players SET choice='$chosen' WHERE id=$id"); } ?>
  12. I have a notifications system and after many late nighters and dr peppers I finally have it working. My only issue is that the notifications "bell" has the number of new notifications in the middle of it. When I click the button it will show me my unread notifications and when I close it the number of unread notifications stays the same. I'm using a sql statement to get the number of unread posts on load but when I click the button to reveal the notifications I'd like it to update the number of unread posts as well. Here's some code I have: //GETS THE NOTIFICATIONS function toggleDiv(divId) { $("#"+divId).show(); $(document).ready(function(){ $("#myContent").load("getnotes.php"); }); } //BUTTON TO PRESS TO SHOW THE NOTIFICATIONS PANEL <a data-ajax="false" href="#myContent" onclick="toggleDiv('myContent');" data-role="button" data-iconpos="notext" class="icon-bell-alt icon-2x" style="background: none; margin-right: 20px;"></a> //SHOWS THE NUMBER OF UNREAD POSTS <div id='notes_number'><? if ($number == "0") { echo $number; } else { echo "<a style='color: #FF0000;'>$number</a>"; }?></div> What can I do to update the number?
  13. Good Day I was wondering if anyone could help me mysql does not seem to be working correctly MySQL server version: -- 5.5.24 the raw MySQL statement in question [mysql_query ("UPDATE ".$db_prefix."banner SET `shown`=0");] any errors that MySQL returns to the client [No ERROR just not updating] the table structure & column indexes of the relevant tables [-- -- Database: `second` -- -- -------------------------------------------------------- -- -- Table structure for table `shc_banner` -- CREATE TABLE IF NOT EXISTS `shc_banner` ( `idx` int(10) unsigned NOT NULL AUTO_INCREMENT, `banner_type` char(3) NOT NULL DEFAULT '', `cat_id` int(10) NOT NULL, `dir_id` char(3) NOT NULL, `banner_order` varchar(255) NOT NULL, `banner_file` varchar(255) NOT NULL DEFAULT '', `banner_title` varchar(255) NOT NULL DEFAULT '', `banner_url` varchar(255) NOT NULL DEFAULT '', `viewslimit` int(11) NOT NULL COMMENT 'After this amount of views has been reached, the ad will be expired. - 0 To disable', `clickslimit` int(11) NOT NULL COMMENT 'After this amount of clicks has been reached, the ad will be expired. - 0 to disable', `banner_target` varchar(255) NOT NULL, `banner_width` int(4) NOT NULL, `banner_height` int(4) NOT NULL, `banner_owner` varchar(255) NOT NULL DEFAULT '', `banner_dir` varchar(1000) NOT NULL, `banner_cat` varchar(1000) NOT NULL, `banner_hits` varchar(255) NOT NULL, `banner_clicks` varchar(255) NOT NULL, `show` int(1) DEFAULT NULL, PRIMARY KEY (`idx`), KEY `banner_type` (`banner_type`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Random Banner' AUTO_INCREMENT=170 ; -- -- Dumping data for table `shc_banner` --] the EXPLAIN output for your query: the query should update the database table but it does not in attached file line 64-67 a clear and concise description of what you want this statement to achieve: That the statment should update my table but it does not a description of what it's currently doing that's not to your liking: its not updating the table/ not even sowing up in debug mode localhost not live if anybody can help I'm new to this and could not find any solution at all Regards Rhino window.php
  14. This query is not working. I need urgent help. Thanks a lot in adv. ROWS affected: 0 I have cross checked the data in the table for the given condition. $sql = 'UPDATE LTE_noria_cellule cel_bk_up SET cel.NAP_'.$site->ur().' = \'1\' '. 'WHERE cel.nidt IN ( select gn from LTE_noria_candidat_bk_up can INNER JOIN LTE_noria_site_bk_up site ON (site.codesite = can.codesite) WHERE '.$site->get_param('zone_bde').')'; I believe problem is because of WHITESPACE. When i search "codesite" in the table with "LIKE". I can't find it. But when i did "LIKE%" , it's working. I tried this also but not working $sql = 'UPDATE LTE_noria_cellule cel_bk_up SET cel.NAP_'.$site->ur().' = \'1\' '. 'WHERE cel.nidt IN ( select gn from LTE_noria_candidat_bk_up can INNER JOIN LTE_noria_site_bk_up site ON trim(site.codesite) LIKE CONCAT('%',trim(can.codesite),'%') WHERE '.$site->get_param('zone_bde').')';
  15. I'm trying to update the info of a record without overwriting what's already there. The database keeps track of donations. Every time someone gives a donation, I want to update their record to keep track of all the donations they've given. In my limited experience with updating a record, I only know how to replace or modify the data. However, I want to just add to it in such a way that will allow me to perform math functions and show a total of their total giving history. MYSQL 5.5.33 PHP: 5.2.17 Any help is appreciated. Thanks, Beck
  16. I am working on converting legacy queries to mysqli prepared statements. My SELECT queries are working fine, but ADD/DELETE/UPDATE are giving me problems. I have found many online examples showing bind statements for ADD/DELETE/SELECT, including the use of call_user_func_array() but others claim that bindings are not necessary when writing records (as opposed to reading them). So I am confused about this issue, and when I use bind statements I get the following error message: Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement in /srv/www/htdocs/PNS/Complex/writeRec5.php on line 177 bind_param()error : The following are snippets of code using dummy values to simplify the code for testing along with output. I reaIize that call_user_func_array() is not necessary in this simple example, but I will need it for the project. I don't see the error, and I have compared it to many online forum examples which claim to be functioning. Does anything stand out? $prepareString = "Address=?,Permit_Rate=?"; echo "<b>PrepareString: </b>",$prepareString,"<br /><br />"; $Address="123 Somewhere Street";$Permit_Rate=25; $sql="UPDATE table1 SET " . $prepareString . " WHERE Key_ID = " . $keyid; echo $sql,"<br /><br />"; Output: PrepareString: Address=?,Permit_Rate=? UPDATE table1 SET Address=?,Permit_Rate=? WHERE Key_ID = 2664 $stmt = $mysqli->prepare($sql); if (false === $stmt) {die('Query Prep Failed' . $mysqli->error);} $dataTypes="si";$bindParams=array(&$Address,&$Permit_Rate); echo "<b>Length of dataTypes: </b> ",strlen($dataTypes),": <b>Contents of dataTypes: </b>",$dataTypes,"<br />"; echo "<b>Count of bindParams: </b>",count($bindParams)," <b>Contents of bindParams: </B>"; var_dump($bindParams); echo "<br /><br />"; Output: Length of dataTypes: 2: Contents of dataTypes: si Count of bindParams: 2 Contents of bindParams: array(2) { [0]=> &string(20) "123 Somewhere Street" [1]=> &int(25) } $x = call_user_func_array(array($stmt, 'bind_result'), &$bindParams); if (false === $x) {die('bind_param()error :' . $mysqli->error);} $stmt->execute();$stmt->close(); Output: Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement in /srv/www/htdocs/PNS/Complex/writeRec5.php on line 177 bind_param()error :
  17. $Database = new $DatabaseClass; $Database->Connect($_POST["host"], $_POST["username"], $_POST["password"], $_POST["database"]); $Database->Update($URL . "messages", "`status`='1'", "`index`='$Index'"); //status and index is INT and everything else is TEXT $Database->Disconnect(); if ($Database->Connect($_POST["host"], $_POST["username"], $_POST["password"], $_POST["database"]) == true) $Access = "Allowed"; $Database->Update($_POST["table"], "lastlogin='" . date("n/j/Y") . "'", "username='" . $_POST["username"] . "'"); //Everything is TEXT $Database->Disconnect(); Both of these code snippets work but I want to know why when I use the update query on the second piece of code I don't need single quotations around anything but I must have them around the first piece of code for it to work at all. Also when I try to use the first piece of code again to change status to a different value with the exact same code it does not work. // This is met when the file redirects to itself via a from submit and passes the following values via POST. This does not work. else if ($_POST["action"] == "delete") { $Database->Connect($_POST["host"], $_POST["username"], $_POST["password"], $_POST["database"]); $Database->Update($URL . "messages", "`status`='2'", "`index`='" . $_POST["deleteindex"] . "'"); //Does not work. $Database->Disconnect(); } I made sure I was able to connect to my SQL database with each snippet of code but I am not able to call the update query consistently. I am also sure that the values I passed in were corrected when I echoed them out.
  18. Update is not working.. UPDATE Customers SET ContactName='Alfred Schmidt', City='Hamburg' WHERE CustomerFirstName='Alfreds' AND CustomerLastName='Futterkiste' Thanks in advanced.
  19. I am building an asset managment system, utilizing some code I found on the net which does live record updates using AJAX, the code is great if I rememeber the link I will post it. However the example code only contains database fields and I need about 14ish, so with my little understanding of the code i started adding more fields. for some reason every time I try to insert the "condition" field the live update stops working for all fields. you can type in new data but does not save back to the database. It happends when i change the code from this: $sql = "update fullnames set AssetID='$AssetID',SerialNumber='$SerialNumber',Type='$Type',Model='$Model' ,Location='$Location' ,Make='$Make' where id='$id'"; mysql_query($sql); to this $sql = "update fullnames set AssetID='$AssetID',SerialNumber='$SerialNumber',Type='$Type',Model='$Model' ,Location='$Location' ,Condition='$Condition ,Make='$Make' where id='$id'"; mysql_query($sql); the full code is attached. I would really apprisiate any help assets.php table_ajax_edit.php
  20. OKay so I am trying to make this simply update my mysql server. Can anyone maybe see why this isn't working? The code all works perfectly up until while statement... So if someone maybe sees something wrong? Thanks... <? session_start(); include('nconnect.php'); $uname=$_POST['to']; $result = mysqli_query($con, "SELECT * FROM messages WHERE to='{$uname}' "); $content=$_POST['content']; while($row = mysqli_fetch_array($result)){ mysqli_query($con, "UPDATE messages SET content='{$content}' WHERE to='{$uname}' "); header('location: p1.php'); } ?>
  21. I am working on a website, where you can have accounts and status'. I want to create a "recent status updates" area but I need a little help. Is there a way to like, check recent updates to a mysql database? like check how recently under the table member the area "status" has been updated? if anyone could point in the right direction for this, it would be quite helpful. And if you maybe need more info to help me, let me know. Thanks!
  22. Hi, I'm trying to make it so the user can enter some text into a text box and from there it will add a link and NOT override it. Here's my problem, I can't seem to get this statement to work correctly as I don't know how to put some kind of variable. Overall: I want it so it adds what ever has been entered into the INPUT tag and add into the correct user_id Please exuse my messy code, I'm just trying to get it to work before I tidy it up. Declared variables at the top of the document: class Users { public $user_id = null; public $username = null; public $email = null; public $password = null; public $salt = "Zo4rU5Z1YyKJAASY0PT6EUg7BBYdlEhPaNLuxAwU8lqu1ElzHv0Ri7EM6irpx5w"; public $links = null; public function __construct( $data = array() ) { if( isset( $data['user_id'] ) ) $this->user_id = stripslashes( strip_tags( $data['user_id'] ) ); if( isset( $data['username'] ) ) $this->username = stripslashes( strip_tags( $data['username'] ) ); if( isset( $data['email'] ) ) $this->email = stripslashes( strip_tags( $data['email'] ) ); if( isset( $data['password'] ) ) $this->password = stripslashes( strip_tags( $data['password'] ) ); if( isset( $data['links'] ) ) $this->links = stripslashes( strip_tags( $data['links'] ) ); } Here's what I've made: public function addLink() { $correct = false; try{ $con = new PDO( DB_DSN, DB_USERNAME, DB_PASSWORD ); $con->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); $sql = "UPDATE `a8906507_members`.`list_members` SET `links` = <SOME KIND OF VARIABLE HERE> WHERE `list_members`.`user_id` = <SOME KIND OF VARIABLE HERE> LIMIT 1"; $stmt = $con->prepare( $sql ); $stmt->bindValue( "links", $this->links, PDO::PARAM_STR ); $stmt->execute(); }catch( PDOException $e ) { return $e->getMessage(); } } Here's my HTML that connects to the public function and executes it. <form action="" method="post" name="add_link" id="add_link"> <table border="0" id="table-add"> <th colspan="2"> <h1>Add a livestream</h1> <?php if( !(isset( $_POST['add_link'] ) ) ) { ?> <?php } else { $usr = new Users; $usr->storeFormValues( $_POST ); $errorMessage = ""; $error = false; if( $usr->addLink() ) { echo 'Channel added!'; $error = false; } else { $errorMessage .= "<li class='error'>Link can't be added</li>"; $error = true; } if($error) { echo($errorMessage); } } ?> </th> <tr> <td> <p>Channel Name:</p> </td> <td> <input type="text" name="channel-name" class="frm-style" /> </td> </tr> <th colspan="2"> <input class="frm-submit-add" name="add_link" type="submit" value="Add" /> <th> </tr> </table> </form> Help will be appreciated, thanks.
  23. updation in profile using email if a person has a account in a website (may be job portal, or any other site) and that person wants to update his profile in his e-mail account without opening his account on that site(job portal), then what will be the code for updating his information in his email itself ?
  24. if (is_array($_POST['uid'])) { foreach($_POST['hours']AS $keyd => $value) { echo "UPDATE participantlog SET noshow=1 AND hours=" . $value . " WHERE cid=" . $cid . " AND uid=" . $keyd . "<br>"; mysql_query("UPDATE participantlog SET noshow='1' AND hours='$value' WHERE cid='$cid' AND uid='$keyd'") or die(mysql_error()); } } For some reason my query isn't executing. The foreach is working properly and producing all the right variables (as verified by the echo). But it just isn't updating the DB. Why might this be? Thanks! Clinton
  25. hi, im a newbie here. im seeking help for my problem. i am also new in php but have some knowledge in sql here's my problem. my boss wants to enable update the baking chamber table once the Estimated End Time reached only. meaning if the end time doesn't meet there will be a pop up on the page that operator cannot finished unless the estimated end time is reached. Please kindly help check my code and see screenshot attached for your reference. Thanks in advanced guys. if($_POST['submit']=="Bake Finished") { $time = strftime('%I:%M %p'); $hours = strftime('%H'); $min = strftime('%M'); $query=mysql_query("SELECT * FROM tbl_baking_chamber"); while($result=mysql_fetch_array($query)) { $recno=$result['RecNo']; if(isset($_POST[$recno])!=NULL) { mysql_query("UPDATE tbl_baking_chamber set tbl_baking_chamber.TotalTime='$TotalTime' where RecNo='".$recno."'"); mysql_query("UPDATE tbl_baking_chamber set tbl_baking_chamber.EndTime='$CurrentDate - $time' where RecNo='".$recno."'"); mysql_query("UPDATE tbl_baking_chamber set tbl_baking_chamber.Status='Finished' where RecNo='".$recno."'"); } } } if($_POST['submit']=="On Baking" || $_POST['submit']=="Bake Finished") { echo "<table class='tbl_Forbaking' cellspacing='1' border='0' width='680'>"; echo "<form action='Applications.php?type=BGABaking' method='post'>"; echo "<tr>"; //echo "<td class='text2' align='center' bgcolor='e3e6e5' height='40'>"."MODEL"."</td>"; echo "<td class='text2' align='center' bgcolor='e3e6e5'>"."SERIAL NUMBER"."</td>"; echo "<td class='text2' align='center' bgcolor='e3e6e5'>"."DEFINED <br> BAKE TIME"."</td>"; echo "<td class='text2' align='center' bgcolor='e3e6e5'>"."BATCH"."</td>"; echo "<td class='text2' align='center' bgcolor='e3e6e5'>"."LOCATION"."</td>"; echo "<td class='text2' align='center' bgcolor='e3e6e5'>"."START TIME"."</td>"; echo "<td class='text2' align='center' bgcolor='e3e6e5'>"."ESTIMATED <br> END TIME"."</td>"; echo "<td class='text2' align='center' bgcolor='e3e6e5'>"."<input type='submit' name='submit' value='Bake Finished' class='btn_Bake'>"."</td>"; $Query = mysql_query("SELECT * FROM tbl_baking_chamber where Status='On Baking'"); $count = mysql_num_rows($Query); $bgcolor="e3e6e5"; while($result = mysql_fetch_array($Query)) { if($bgcolor=='e3e6e5') { $bgcolor='e9ebea'; } else { $bgcolor='e3e6e5'; } echo "<tr>"; //echo "<td class='text1' align='center' bgcolor='$bgcolor'>".$result['Model']."</td>"; echo "<td class='text1' align='center' bgcolor='$bgcolor'>".$result['Serial']."</td>"; echo "<td class='text1' align='center' bgcolor='$bgcolor'>".$result['BakingHours']."</td>"; echo "<td class='text1' align='center' bgcolor='$bgcolor'>".$result['Batch']."</td>"; echo "<td class='text1' align='center' bgcolor='$bgcolor'>".$result['Chamber']."</td>"; echo "<td class='text1' align='center' bgcolor='$bgcolor'>".$result['StartTime']."</td>"; echo "<td class='text1' align='center' bgcolor='$bgcolor'>".$result['SEndTime']."</td>"; echo "<td class='text1' align='center' bgcolor='$bgcolor'>"."<input type='checkbox' value='$result[RecNo]' id='$result[RecNo]' name='$result[RecNo]'>"."</td>"; } echo "</form>"; echo "<tr>"; echo "<td>"."<br/>"; echo "<tr>"; echo "<td class='text4'>"."Total QTY.: $count"; echo "</table>"; }
×
×
  • 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.