Linking To Update Database In Printf Statement

May 7, 2001

I have the following statement:

printf("<tr><td class="ltgrey">%s<td class="ltgrey">%s, %s</td><td class="ltgrey">%s<td class="ltgrey">%s<td class="ltgrey">%s</tr>",

$myrow["client"], $myrow["last"], $myrow["first"], $myrow["phone"], $myrow["email"], $myrow["url"]);

and wish to have the client displayed as a link so that a user can clik on it to update the information in the db. How can i do this?

ADVERTISEMENT

Printf - Warning: Printf() [function.printf]: Too Few Arguments

Feb 21, 2006

what im doing wrong? PHP Code:

mysql_connect("localhost","goc2d_Audio","*****") or die ("Cant connect to db");
    mysql_select_db("goc2d_main") or die ("Cant select db");
    $result = mysql_query('SELECT * FROM `news`') or exit(mysql_error());
    while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
        printf ('
        <table width="95%" border="1" cellspacing="0" cellpadding="0">
        <tr>
        <td>%s</td>
        </tr>
        <tr>
        <td>%s</td>
        </tr>
        </table>
        ', $row[0], $row[1]);
        }
    mysql_free_result($result);
    mysql_close();

Warning: printf() [function.printf]: Too few arguments in /home/goc2d/public_html/delta/index.php on line 38

it works fine if i leave the table as <table>

View 1 Replies View Related

Use Commit The Statement After Each Update Statement?

Jul 2, 2009

Should I use commit the statement after each update statement?Is it a good practice to do it.

Code:
foreach ($array as $key => $value)
{
[code].........

View 5 Replies View Related

Update Statement Doesn't Update?

Jul 15, 2011

I have a form which passes 3 values x 14 instances to a processing page. I am getting the arrays of the variables and am able to echo to screen to check that the pairs of values that I want are there.  This all works OK. Then I have an update statement which should go to the sprcified table, update the column with the values from the arrays where the condition is met.

However, it just isn't updating.  I don't get an error message unless there is a problem in the code (I set one to check it, then took it out).My code is below, could someone please look and tell me if they can see the problem.  I connect to my database by calling a connect file, which is correct as it is getting the information for the form page correctly.  I'm going cross eyed looking at it now.

Code: [Select]<?php
//database connection
include'myconnect.php';[code]...

View 4 Replies View Related

Update Statement

Jul 25, 2006

I have hit a slight problem - I have an update statement as follows:

$conn->Execute("UPDATE units SET $res = $newrescost WHERE ID = $x");

The problem is that it comes up with an error about the syntax - I am sure I have everything covered that I need to though. The statement works but I have a text box which appears for each resource for the unit which I want to edit - it only shows the first one,

then if you click it and hit enter it shows the first 2, then the first 3, then all 4 (there are only 4 resources in this game at the moment). Can anyone see what the problem could be, given that $conn is the connection to the database, $res is the resource name taken from the resources table, $newrescost is the new cost (written into the textbox) and $x is the ID of the unit to be edited?

View 7 Replies View Related

PHP/SQL Update Statement

Jun 26, 2007

i'm having some problem with my update statment. Here is a form with disabled and prefilled fields. Every field has an edit button. Form.php(bottom of page) doesn't update the table. Is the statement wrong? Im sure that "Seinfeld" is in the database and kunde is the correct table.

Could it be the disabled/prefilled fields causing the problem since they have an initial value? I edited fornavn(firstname) and etternavn for updating. After the update it should print to screen that the update is done, this never happens so clearly the statement isn't working. I tried using insert with empty table and that worked no prob. Code:

View 5 Replies View Related

Update Statement Not Effective?

Jun 24, 2011

<?php
.
.
.
mysql_connect($host,$username,$password);
if (!mysql_select_db($database))

[code]....

The script will edit and replace the field with new information gained by input. It will echo Success as expected, but the row hasn't changed.

View 2 Replies View Related

Update Statement Does Not Display Anything ?

Mar 30, 2009

my update statement, it does not display anything

$sqlString = "UPDATE cms_users SET email = '$email', passwd='$passwd', name='$name', Address='$Address', TelNo='$TelNo', MobileNo='$MobileNo', Job_TItle = '$Job_TItle', Positions = '$Positions' where user_id='$user_id'";

mysql_query($sqlString)
or die("Error in query $sqlString" . mysql_error());

View 10 Replies View Related

UPDATE Prepared Statement?

Feb 7, 2011

I have a problem with UPDATE prepared statement, looked everywhere, browsed through questions here, and the syntax seems to be right, what am I missing?

$update_page = $db->stmt_init();
$update_page = $db->prepare ("
UPDATE pages
[code]....

View 2 Replies View Related

Update SQL Statement Not Working?

Nov 29, 2009

I have this page that outputs information into a table of rows. On clicking edit, it allows the user to edit the data in that row and press update, I have echoed out an "Update successful" statement after the SQL update query which is placed inside an IF statement so as far as i can see the SQL is executing but not updating my table.

Code:

<?php
$host = localhost;
$user = bw001500;

[code]...

View 7 Replies View Related

Update Statement With Querystring

Aug 4, 2009

I have the code below where i want to update fields in my database. Now i know the insert statement does work because i have tested it with test data. But when i do the following:-

Quote:
$update_thread = "UPDATE threads SET thread_message = '".$_POST['txt_subject']."' WHERE thread_id =" .$_GET['thread_id'];
$add_member = mysql_query($update_thread);
$update_post = "UPDATE posts SET post_message = '".$_POST['txt_subject']."' WHERE thread_id =". $_GET['thread_id'];
$add_member = mysql_query($update_post);
header("Location: http://www.listentotheconstituents.com/posts.php?post_id=" .$_GET['post_id']. "&thread_id=" .$_GET['thread_id']);

It does not pick up ANY of the lines that have this .. $_GET['thread_id']

View 6 Replies View Related

Update Statement Only Working Once?

Jun 17, 2010

don't understand why the update statement only works once.. and after it rolls another 6, it wont add aother 500 to the RP amount.

<?php
session_start();
include("logincheck.php");
?>
[code]....

View 7 Replies View Related

Update Statement Getting An Error?

Dec 24, 2010

syntax error, unexpected T_VARIABLE, expecting ',' or ';' in ds.php on line 6

This is my code
include_once("db_conn.php");
[code]......

View 3 Replies View Related

How Does The UPDATE Statement Work

Mar 14, 2007

I have found that the tutorial I was using and basing my UPDATE statement does not work and the answers I have gotto so far, I am sorry to say, I do not understand.

I have a number of PHP books available to me but they skirt over the update issue

So please anyone could you point me to a tutorial  where I can select a simple record from a file display the fields and update the file with any modifications.

View 1 Replies View Related

Dynamic Update/insert Statement?

Nov 18, 2002

I'm hoping to build a dynamic sql statement for inserts and updates based on FORM values. I've done this in ASP but not sure about PHP syntax. Right now I just output the form entry results, but here's what I'm thinking for an update: PHP Code:

View 11 Replies View Related

SQL Statement - $sql = "UPDATE Tbl_pistols_image

Mar 3, 2007

I have this script: PHP Code:

$sql = "UPDATE tbl_pistols_image
                SET im_album_id = $albumId,
                    im_title = '$imgTitle',
                    im_description = '$imgDesc',
                    im_image = $image,
                    im_thumbnail = $thumbnail,
                    im_date = NOW()
                WHERE im_id = $imgId";

View 5 Replies View Related

Prepare Statement For Update Query?

Jun 29, 2011

I have a mysqli query $db_usag->query("UPDATE Applicant SET phone_number ='$phone_number', street_name='$street_name', city='$city', county='$county', zip_code='$zip_code', day_date='$day_date', month_date='$month_date', year_date='$year_date' WHERE account_id='$account_id'");. However all the data is extracted from html documents so to avoid errors I would like to use prepare statement. I found php documentation but there is no UPDATE example [URL]

View 1 Replies View Related

Update Statement Doesn't Do Anything To Table?

Apr 20, 2011

I get no errors and all my print statements are telling me i'm doing a good job, yet my field under the desired column stay the same. what is happening (or rather not happening)?

if ($current && $new) {// the validation code is left out
$sqlTekst = "UPDATE gebruikers SET pasW = ". $_POST[nieuwPasw] ." WHERE gebruikersNr = ". $_POST[gebruikersNr];
print 'huidig POST gebruikersNr = $_POST[gebruikersNr]';[code]....

View 5 Replies View Related

Load Variables Into An Sql UPDATE Statement?

May 23, 2009

I am pulling user input from a from using POST method. I am loading that input into variables. And I am trying to load those variables into an sql UPDATE statement.

$db_addClient = "UPDATE tbl_client SET clientName =" .$cName. ", contactName =" .$cContact. ", phoneNum =" .$cPhone. ", email =" .$cEmail. ", description =" .$cDescription. ", notes =" .$cNotes. ", entryDate =" .$cDate. " WHERE clientID =" .$id;
$result = mysql_query($db_addClient)or die("Edit Client Query Failed: " . mysql_error());

I can get numbers to work but if I enter text it throws an error. the error I get is QuoteEdit Client Query Failed: Unknown column 'EnteredText' in 'field list'

View 4 Replies View Related

Get Error When UPDATE Mysql Statement?

Nov 16, 2010

ive tried to write the $sql in so many ways and this looks the best and its still not workingand ive checked the correct syntax but still.

this is how i wrote:
$sql2 = "UPDATE `tvchaty`.`episodes` SET `showid` = ".($showid).", `epname` = ".($epname).", `season` = ".($season).", `episode` = ".($episode).", `info` = ".($info).", `airdate` = ".($airdate).", `directwatch` = ".($directwatch)." WHERE `episodes`.`id` = ".($id)." LIMIT 1;";   
[code]....

View 4 Replies View Related

Add A Conditional Statement To My Update Record Form.

Dec 19, 2005

I wish to add a conditional statement to my update record form. Basically the form has an image upload feature and I wish to make it so that only if an image is specified should that field be updated, otherwise it should just ignore updating that field. The update code is below:

$updateSQL = sprintf("UPDATE news SET Type=%s, Headline=%s, Poster=%s, Summary=%s, Content=%s, Image=%s, `Date`=%s, Disabled=%s WHERE Id=%s", GetSQLValueString($HTTP_POST_VARS['type'], "int"),
GetSQLValueString($HTTP_POST_VARS['headline'], "text"),
GetSQLValueString($HTTP_POST_VARS['poster'], "text"),
GetSQLValueString($HTTP_POST_VARS['summary'], "text"),
GetSQLValueString($HTTP_POST_VARS['content'], "text"),
GetSQLValueString($HTTP_POST_VARS['image'], "text"),
GetSQLValueString($HTTP_POST_VARS['date'], "date"),
GetSQLValueString(isset($HTTP_POST_VARS['disabled'
]) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString($HTTP_POST_VARS['Id'], "int"));

I have tried inserting an if statement around the particular field but this caused the page to flip out and generate errors all over the place.

View 8 Replies View Related

SQL: Using A CASE Statement To Update 1000 Rows At Once?

May 5, 2010

I would like to use a CASE STATEMENT for this, but I am lost with this. Basically, I need to update a ton of rows, but just on the "position" column. I need to UPDATE all position values that are great than the position value that was removed to position - 1 on a per id_layout and id_layout_position basis. here is a pic of what the table looks like: Now let's say I delete the circled row, this will remove position = 2 and give me: 0, 1, 3, 5, 6, 7, and 4. It should reposition the position values that are greater than 2, so that it looks like this: 0, 1, 2, 4, 5, 6, and 3.

Here's what I got so far within the DELETING of the ROW, so here's how it looks for this (NOTE: $module_info['clones'] = an array of clones to delete, in the table above there would be none, because all id_clone values are 0, and $module_info['id'] is the id_module value that we are removing):

// Get rid of id_clone = 0, because we can't use them.
$module_info['clones'] = array_values(array_filter($module_info['clones']));

[code]...

There's Just gotta be some sort of way to use a CASE STATEMENT in this UPDATE now. For Example, I now need to update all positions to position - 1, on a per id_layout, and per id_layout_position basis. BUT only where the position is greater than the current position for that id_layout and id_layout_position value.

View 2 Replies View Related

UPDATE Statement Not Working, Moved Server?

Jun 3, 2010

I moved from PHP 4.4.9 on 1and1, to my VPS, using 5.2.12 and I cannot get basic UPDATE statements to work.I tested this basic script I found on my hosting and it does nothing, the page is supposed to refresh when you hit submit, and show the new value from the database.I found the code here, and I know this exact code works on my other hosting.PHP Code:

<?php
$host="localhost"; // Host name
$username=""; // Mysql username

[code]...

View 6 Replies View Related

MySQLi Prepared Statement With Dynamic Update Query?

Jul 9, 2011

I'm busy changing from normal mysql_queries to prepared statements, now I found a function that generated a dynamic query based on how many fields were not empty.

I managed to convert it so it runs each field as a separate query, but is there a way to put all these queries into one query without converting to PDO ?

public function edit($ticket_id, $department_id = '', $location_id = '', $ticketcat_id = '', $ticketsta_id = '',
$ticketmed_id = '', $ticketpri_id = '', $ticket_assigned = '', $ticket_plandate = '',

[Code]....

View 1 Replies View Related

Update Statement Not Working Properly With $_GET And INNER JOIN

May 30, 2011

For some reason my update statement below is not updating the student name when I use the where clause with the student_id as one of the conditions. When I use the trainer_id it update all of the students under that trainer, but I only want to the statement to update that specific student detail such as the surname.

An extract from the code is below:

PHP Code:

<?php
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if (isset($_POST['submit'])) {
// Grab the profile data from the POST
$first_name = mysqli_real_escape_string($dbc, trim($_POST['firstname']));

[Code].....

View 3 Replies View Related

Update - PDO Prepared Statement Query Not Updating Record?

Jan 23, 2010

I am having a problem using PHP's PDO object to prepare an update statement and updating the record. I have taken the raw SQL query and ran it in phpMyAdmin with the params replaced by their values that are passed to the function. Which updates the record as intended. However, when ran from the script it does not update. It throws zero errors and it returns an errorInfo() reply of 00000, which to my understanding is PDO's way of saying all is well. I know the PDO object works because it successfully inserts and selects records from the database, including the one I am trying to update. I understand this update function is ugly, I am just learning PDO.

foreach($where as $key => $val)
{
[code]....

View 2 Replies View Related

Update Statement Causes Mysql Varchar Field To Be Set To Empty String

Mar 9, 2006

I have come across a problem that has me baffled.

I am using PHP with MySQL 4.1.14. Whenever I execute an update
statement against a specific table, some of the varchar fields do not
get set to the new values, but get set to empty strings instead.

I have simplified the code down to updating a single column in the
table, but the same results happen when updating just the single
column.

Here is the stripped down code which causes the problem:

$queryString = "UPDATE REGISTRATION SET passwd = '$pass'' WHERE id =
388";
$db = mysql_connect("hostname", "user", "pass");
mysql_select_db("CUSTOMER", $db) or die(mysql_error());
mysql_query($queryString, $db) or die(mysql_error());

Printing the query string after executing mysql_query shows the
following query:

UPDATE REGISTRATION SET passwd = 'test' WHERE id = 388

This query updates the column successfully when run directly through
phpMyAdmin. When run through PHP using the code above then column is
set to an empty string value.

There is no error returned if I call mysql_error() nor is there any
unusual info returned from mysql_info() (other than it telling me that
1 row was affected).

Does anyone have any ideas what the underlying problem is on this one?
Could be an attribute of the database table or columns that would cause
this behavior? I have racked my brain for a while over this problem.

View 2 Replies View Related

Printf

Jul 17, 2005

$sum_value+=$row_array[8];
}
echo "</table>";
echo "<br>Total Value of Orders: ".printf('$%01.2f',
$sum_value)."<br>";
echo "</br>Done";

Result in this? $20500.00 Total Value of Orders: 9.

View 3 Replies View Related

Printf(): Too Few Arguments

Feb 6, 2002

I'm sure this is a simple problem, but it's driving me nuts. I'm still new to php and mysql...I am learning quick though. I have tried adding in numerous $myrow=["null"] values to the end but it still gives me the same error just with a new line number.

View 1 Replies View Related

Printf() Format

Jul 10, 2000

I have a problem to output the format of printf().

<?
$year=2000;
$month=7;
$day=9;
printf("%d%d%d",$year,$month,$day);?>

How to output to "20000709" using printf()? I must use the function printf().

View 3 Replies View Related

Store Printf Value

Jul 17, 2005

Using printf, I can get the output I want:

printf("ch: 6%u
",$ch);

The %u allows me to convert a negative value to an unsigned decimal number. My problem is that I don't want to output this to the screen. I need to store it as a variable.

View 4 Replies View Related

Printf Align Right

Feb 12, 2006

I am using printf to display some text and numbers. having been through the professional PHP programmnig book, it suggests the following for what I am trying to acheive

printf(" %'.-18.18s%'.3d%s", $img_str, $num_images, "<br />");
  printf(" %'.-18.18s%'.3d%s", $imgcnt_str, $num_hits, "<br />");
  printf(" %'.-18.18s%'.3d%s", $imgcol_str, $collections, "<br />");

however it doesn't have the deisred results. I think this may be because of the sizes of the characters, I attatch an image of what I want to acheive, and it includes at the bottom the output of the code above.

Any ideas how I can achieve the style at the top of the pic?

View 2 Replies View Related

Printf And Sprintf Where Exactly ?

Feb 22, 2011

Possible Duplicates: PHP sprintf() and printf() functions .Why use sprintf function in PHP? Printf and sprintf where exactly used in php? give one example?

View 2 Replies View Related

Printf In Smarty

Nov 12, 2007

I am using Smarty (->smarty.php.net) and I want to show this:

  printf($lang['users_online'],'$total_online_users');

How would I assign that with smarty using this:
$template->assign('TOTAL_USERS_ONLINE, 'what the above outputs);

View 1 Replies View Related

Printf Function

Apr 23, 2007

How do get the $disc_total and round($TotalCost/12, 2) to work with printf? Code:

View 5 Replies View Related

Printf Formatting

Jul 14, 2007

I am trying to format 2 numbers 182.75 * 2 using

printf("%09.2f" , ($rs['Cost'] *  $rs['Q'])  )

instead of getting 000365.50 I get 000365.509 the last digit is the number of zeros on the end. This is a shopping basket totals.

View 6 Replies View Related

Display % Sign With Printf

Oct 9, 2001

I am facing difficulty in printing % sign with printf. How do I display % sign in printf commands.

View 1 Replies View Related

Printf() With Control Character

May 15, 2006

I'm trying to write a rotational symbol in a CLI process, to report
activity to the user console, using printf( "%s", symbol ); but I see
the control character () is been printed out instead of backspacing.

Is there any work around ?

View 5 Replies View Related

Calling A Function Within Printf()

Apr 25, 2006

I am using the printf function to display the rows from my query. Everything works fine, but I want to add a custom function that will format the $extended_price variable so that this number is displayed with commas for numbers in the thousands.

The custom function that I created is called NumberWithCommas, and I want to call it within the prinf function. I tried doing it by adding ".NumberWithCommas($extended_price)." in place of $extended_price, but this did not give me the result I was looking for. Code:

View 2 Replies View Related

Thousands Separator With Printf?

May 3, 2011

How do do a thousand seperator (like a comma) in a printf?

example:

printf("<td class='number'>%d</td>", $totals['Sold']); //need thousand separated
printf("<td class='number'>%.2f</td>", $totals['Fees']); //need thousand separated

UPDATE this is what i had originally:

foreach(array_keys($totals) as $key){
if(is_numeric($totals[$key])){
$totals[$key] = number_format($totals[$key],2);
}
}

[Code]....

View 3 Replies View Related

Path - Where Does Printf's Output Go

May 19, 2011

This is my first time working on php code. I've put some printf code in it and wonder where the output goes?

edit

I'd like to debug this php code. Don't know if there's a debugger for php but I can print a log.

View 2 Replies View Related

Decimal -> Float With Printf

Jun 29, 2007

I've tried to do this conversion but no luck until now.
Is it actually possible convert

from 0000000133400 to  13.3400
using printf ?

I would be very grateful if anyone out there could give me a hand with this one.

View 4 Replies View Related

Is There Something Similar To Printf For Writing To Files?

Sep 24, 2000

Is there something similar to printf for writing to files? Right now, my code is this

function PrintEmployees($input_array)
{
while(list($index, $value) = each($input_array))
{
printf ("%s (%s) %.2f <BR>n",
$value[0],
$value[1],
$value[2]);}}

But instead of printing to the browser, I want to write the same output to a file. How do I do this? Can it be done with fputs?

View 1 Replies View Related

Formatting A Number (or String) Without Printf

Jul 26, 2000

Right now I have a number ie: 80.5 I need to change this to: 80.50
Using printf I would use: printf("%.2f", 80.5); But I don't want to print it out.

View 2 Replies View Related

The Or Operator - Printf Function Is Executed

Nov 18, 2005

I am having a problem with the following code: PHP Code:

$query = "SELECT * FROM rates";
    $result =& $link->query($query) or
        printf ("There was an error looking up rates: <b>%s</b><br>QUERY: %s<br>",
        $link->error, $query);

No matter what the printf function is executed. I don't think it's because of the =& operator, could it be because of the object?

View 5 Replies View Related

ADVERTISEMENT