I'm writing a work order system using PHP and MySQL and I'm stuck on two things-transferring data and updating the data.
Here is my code:
i'm using checklogin.php to do most of everything so it's most likely something I'm missing here.
checklogin.php
Now for my second problem.
update.php -
-
<html>
-
<?
-
-
$ID=$_GET['ID'];
-
$username="gancsosa";
-
$password="*****";
-
$database="gancsosa_crystalworks";
-
mysql_connect("example.com",$username,$password);
-
@mysql_select_db($database);
-
$query=" SELECT * FROM inprogress WHERE ID='$ID";
-
$result=mysql_query($query);
-
mysql_close();
-
-
-
//Print output
-
-
$Client=mysql_result($result,"Client");
-
$Number=mysql_result($result,"Number");
-
$Address=mysql_result($result,"Address");
-
$Issue=mysql_result($result,"Issue");
-
$Notes=mysql_result($result,"Notes");
-
$Status=mysql_result($result,"Status");
-
$Charge=mysql_result($result,"Charge");
-
-
?>
-
-
<form action="updated.php" method="post">
-
<input type="hidden" name="ud_ID" value="<? echo $ID; ?>">
-
Client: <input type="varchar(56)" name="ud_Client" value="<? echo $Client; ?>"><br>
-
Address: <input type="text" name="ud_Address" value="<? echo $Address; ?>"><br>
-
Number: <input type="bigint(20)" name="ud_Number" value="<? echo $Number; ?>"><br>
-
Issue: <input type="longtext" name="ud_Issue" value="<? echo $Issue; ?>"><br>
-
Notes: <input type="longtext" name="ud_Notes" value="<? echo $Notes; ?>"><br>
-
Status: <input type="tinyint(1)" name="ud_Status" value="<? echo $Status; ?>"><br>
-
<input type="Submit" value="Update">
-
</form>
-
-
<?
-
//Update
-
$ud_Address=$_POST['ud_Address'];
-
$ud_Number=$_POST['ud_Number'];
-
$ud_Issue=$_POST['ud_Issue'];
-
$ud_Notes=$_POST['ud_Notes'];
-
$ud_Status=$_POST['ud_Status'];
-
-
-
$username="gancsosa";
-
$password="*****";
-
$database="gancsosa_crystalworks";
-
mysql_connect("example.com",$username,$password);
-
@mysql_select_db($database) or die( "Unable to select database");
-
-
$query="UPDATE inprogress SET Address='$ud_Address', Number='$ud_Number', Issue='$ud_Issue', Notes='$ud_Notes2', Status='$ud_Status' WHERE ID='ud_ID' ";
-
mysql_query($query);
-
mysql_close();
-
-
?>
-
-
-
</html>
-
-
Any help would be GREATLY appreciated.
35 9571
Anyone? Any ideas? ..............
Thank you for replacing my actual information. LOL I was quite worried about everyone seeing it.
Atli 5,058
Expert 4TB
Hey.
What are you having problems with, exactly?
What are you expecting the code to do? What is it actually doing?
Are you getting any error messages? - We LOVE error messages :) (Keep in mind that we can't actually run the code on our own test machines.)
A few things I notice, though, that may help. - In both of your code examples, you connect to MySQL twice. This is unnecessary, and a waste of resources. A single call to the mysql_connect function is enough, unless you have a specific reason for needing to call it more often.
- On lines #31 and #32 you use the session_register function. This function is deprecated and should not be used anymore. - Instead, you should register session variables like so:
- $_SESSION['username'] = $username;
- Indentation - You should always write your code as if the guy who will be maintaining it is a homicidal maniac that knows where you live. It will make your own work on the code easier, and it makes it easier for people like myself - who were not involved in writing it - to work on it.
Thank you for the response and advise.
No error messages. It's just not transferring the information from one table to another.
When I go into the data page, I want to make sure that the data is in the right tables.
Atli 5,058
Expert 4TB
Ok, so after going a bit more thoroughly over it, I think I've found what is causing your main problem. #1
In your second script, "update.php", you have a SQL query at the very end of it, line #54. - The problem is the WHERE clause. Instead of using the "ud_ID" from the form (the $_POST array), you are using the name as a static string. That will cause MySQL to either fail with an error (which you don't seem to even check for), or always update the first row. - Either way, you need to replace that with the value passed from the form. (Like you do with the other values in that query.) #2
Earlier in that script, you do this: - $Client=mysql_result($result,"Client");
-
$Number=mysql_result($result,"Number");
-
$Address=mysql_result($result,"Address");
-
// etc...
This is incorrect usage of the mysql_result function. Instead, you should be fetching the entire row using the mysql_fetch_assoc function and using the return array you get from that. - $row = mysql_fetch_assoc($result);
-
$Client=$row['Client'];
-
$Number=$row['Number'];
-
$Address=$row['Address'];
-
// etc...
#3
On line #13 of the second example, you have a SQL query. It is missing a quotation mark at the end. The single-quote after the $ID is missing. It needs to be added. - Also, there is an extra space in front of the SELECT that should be removed. #4
I don't see anything in the first code that would "break" it. It should work, even though there are a few things that could use some "tuning". - However, there is one thing that should be removed or fixed. On line #56 you have a SQL query that is just... wrong. - There is no such thing as a UPDATE INTO query. -Not sure exactly what you were trying to do there, but I would simply remove that line.
Hope that helps any.
LOL!!!! Yeah, I had INSERT INTO and it wouldn't transfer the data so I tried out the UPDATE. LOL!!!! I'm not THAT much of a PHP noob. Am I?
I did what you told me to, but unfortunately it still doesn't update the data. :(
I got it to transfer from table to table, but it still doesn't update for some REALLY annoying reason. I'm either being really stupid or something's dumb with the code....
Atli 5,058
Expert 4TB
How does your update script look now?
-
-
<html>
-
<?
-
-
$ID=$_GET['ID'];
-
$username="gancsosa";
-
$password="************";
-
$database="gancsosa_crystalworks";
-
mysql_connect("njcomputermedic.fatcowmysql.com",$username,$password);
-
mysql_select_db($database);
-
$query="SELECT* FROM gancsosa_crystalworks.inprogress WHERE ID='$ud_ID' ";
-
$result=mysql_query($query);
-
-
-
//Print output
-
$row=mysql_fetch_assoc($result);
-
-
$ID=$row['ID'];
-
$Client=$row['Client'];
-
$Number=$row['Number'];
-
$Address=$row['Address'];
-
$Issue=$row['Issue'];
-
$Notes=$row['Notes'];
-
$Status=$row['Status'];
-
$Charge=$row['Charge'];
-
-
?>
-
-
<form action="updated.php" method="post">
-
<input type="hidden" name="ud_ID" value="<? echo $ID; ?>">
-
Issue: <input type="longtext" name="ud_Issue" value="<? echo $Issue; ?>"><br>
-
Notes: <input type="longtext" name="ud_Notes" value="<? echo $Notes; ?>"><br>
-
Status: <input type="tinyint(1)" name="ud_Status" value="<? echo $Status; ?>"><br>
-
<input type="Submit" value="Update">
-
</form>
-
-
<?
-
//Update
-
$ud_ID=$_POST['ud_ID'];
-
$ud_Issue=$_POST['ud_Issue'];
-
$ud_Notes=$_POST['ud_Notes'];
-
$ud_Status=$_POST['ud_Status'];
-
-
-
$username="gancsosa";
-
$password="***********";
-
$database="gancsosa_crystalworks";
-
mysql_connect("*******************",$username,$password);
-
-
$query="UPDATE gancsosa_crystalworks.inprogress SET Issue='$ud_Issue', Notes='$ud_Notes2', Status='$ud_Status' WHERE ID='$ud_ID' ";
-
-
mysql_query($query);
-
-
?>
-
-
-
</html>
-
Atli 5,058
Expert 4TB
Line #11. The WHERE clause is using the wrong ID variable. It is using $ud_ID where it should be using $ID. (The $ud_ID variable is created later in the code.)
I changed that and I even tested the value of ID that the _GET function was pulling in and it printed nothing. So I'm guessing it's not updating because it's not pulling in the information because it's not pulling in the ID :(
Atli 5,058
Expert 4TB
How does the URL you are requesting look like?
The "$ID=$_GET['ID'];" line is pulling the ID from the URL, so it should look something like: http://localhost/update.php?ID=xx
Where "xx" is the ID of the record you are trying to update.
Okay, so i made it http://localhost/update.php?ID=01.
It takes in the information, but doesn't update the table with new information after submit has been clicked. I'm guessing it's something with my query....
Okay, I got everything working. Thank you VERY VERY much. My problem right now it that I can only update that one ID and I have a loop to print out the data with a unique link which includes that ID. That being said, is there some way that I can make the ID an incrementing int like in C++ or JAVA?
okay, so i was screwing around with making cookies for the site and my update script just stopped working. maybe it's something small that i'm missing, but can someone help me again? -
-
<html>
-
<?
-
$ID=$_GET['ID'];
-
$username="***************";
-
$password="***************";
-
$database="****************";
-
mysql_connect("*******************",$username,$password);
-
mysql_select_db($database);
-
$query="SELECT* FROM ********** ";
-
$result=mysql_query($query);
-
-
-
//Print output
-
$row=mysql_fetch_assoc($result);
-
-
$ID=$row['ID'];
-
$Time=$row['Time'];
-
$Client=$row['Client'];
-
$Number=$row['Number'];
-
$Address=$row['Address'];
-
$Issue=$row['Issue'];
-
$Notes=$row['Notes'];
-
$Status=$row['Status'];
-
$Charge=$row['Charge'];
-
-
-
//Print "ID: $ID<br>";
-
?>
-
-
-
<form method="POST">
-
<input type="hidden" name="ud_ID" value="<? echo $ID; ?>">
-
Client: <input type="text" name="ud_Client" value="<? echo $Client; ?>"><br>
-
Address: <input type="text" name="ud_Address" value="<? echo $Address; ?>"><br>
-
Number: <input type="bigint(20)" name="ud_Number" value="<? echo $Number; ?>"><br>
-
Issue: <input type="longtext" name="ud_Issue" value="<? echo $Issue; ?>"><br>
-
Notes: <input type="longtext" name="ud_Notes" value="<? echo $Notes; ?>"><br>
-
Status: <input type="tinyint(1)" name="ud_Status" value="<? echo $Status; ?>"><br>
-
Charge: <input type="double" name="ud_Charge" value="<? echo $Charge; ?>"><br>
-
<input type="Submit" value="Update">
-
</form>
-
-
<input type="Submit" onClick="window.close()" value="Close Window">
-
<?
-
-
//Update
-
$ud_ID=$_POST['ud_ID'];
-
$ud_Client=$_POST['ud_Client'];
-
$ud_Number=$_POST['ud_Number'];
-
$ud_Address=$_POST['ud_Address'];
-
$ud_Issue=$_POST['ud_Issue'];
-
$ud_Notes=$_POST['ud_Notes'];
-
$ud_Status=$_POST['ud_Status'];
-
-
//Print "ID: $ID<br>";
-
//Print "ud_ID: $ud_ID<br>";
-
-
mysql_query("UPDATE inprogress SET Time=NOW(),Client='$ud_Cleint',Number='$ud_Number',Address='$ud_Address',Issue='$ud_Issue',Notes='$ud_Notes,Status='ud_Status',Charge='$ud_Charge' WHERE ID='$ID' ");
-
-
?>
-
-
-
</html>
-
-
i realized that one of the reasons why i'm having trouble updating is because my for is inserting more than one row giving it the same id.
work_order.php -
-
<div id=icon style="position:absolute;left:900">
-
-
<img src="http://www.1fixcomputermedic.com/Pictures/Site/ambulance.jpg">
-
-
</div>
-
-
<div id=cm style="position:absolute;">
-
-
<img src="/Pictures/Site/work_order.jpg"><br>
-
-
<br>
-
-
</div>
-
-
<div id=data style="position:absolute;top:300;">
-
<form id="workOrder" method="POST">
-
<input type="hidden" name="ID" value="<? echo $ID; ?>">
-
Client:<input type="text" name="Client" value="<? echo $Client; ?>"><br>
-
Number:<input type="bigint(20)" name="Number" value="<? echo $Issue; ?>"><br>
-
Address:<input type="text" name="Address" value="<? echo $Issue; ?>"><br>
-
Issue: <input type="longtext" name="Issue" value="<? echo $Issue; ?>"><br>
-
Notes: <input type= "longtext" name="Notes" value= "<? echo $Notes; ?>"><br>
-
Status: <input type="tinyint(1)" name="Status" value="<? echo $Status; ?>"><br>
-
Charge: <input type="tinyint(1)" name="Charge" value="<? echo $Charge; ?>"><br>
-
-
<input type="Submit" value="Submit">
-
</form>
-
</div>
-
-
<?
-
//Get data from form
-
$ID=$_POST['ID'];
-
$Client=$_POST['Client'];
-
$Number=$_POST['Number'];
-
$Address=$_POST['Address'];
-
$Issue=$_POST['Issue'];
-
$Notes=$_POST['Notes'];
-
$Status=$_POST['Status'];
-
$Charge=$_POST['Charge'];
-
-
//Insert new data into inprogress
-
-
$query="INSERT INTO inprogress (Client,Time,Number,Address,Issue,Notes,Status,Charge) VALUES ('$Client', NOW(), '$Number', '$Address','$Issue','$Notes','$Status','$Charge') ";
-
-
mysql_query($query);
-
-
mysql_close();
-
?>
-
-
-
</html>
-
-
now when i go into the mysqladminphp i get the correct values from the work order, but i still can't update anything.... any ideas?
Atli 5,058
Expert 4TB
Hey.
The two previous code examples, are the exactly like they are on your server? (Meaning; you didn't copy/paste small parts of them, but the whole thing)
If so, I see a problem with both of them.
For example, the update script in post #18. - The UPDATE query is the last thing on the page, but it ALWAYS executes, even when there has no data been posted. Even the first time you see it, and the form is displayed, the UPDATE query is executed but with no values.
You need to make sure the values you are inserting into the query are valid.
Generally you should try to do something like this: - <?php
-
// Check if the updated values have been sent.
-
if(isset($_POST['id'], $_POST['newValue1'], $_POST['newValue2']))
-
{
-
// Fetch the updated values, making sure they
-
// are safe to use in the SQL query.
-
$id = (int)$_POST['id'];
-
$newValue1 = mysql_real_escape_string($_POST['newValue1']);
-
$newValue2 = mysql_real_escape_string($_POST['newValue2']);
-
-
// Create and execute the SQL query
-
$sql = "UPDATE `table` SET
-
`value1` = '$newValue1',
-
`value2` = '$newValue2'
-
WHERE
-
`id` = $id
-
LIMIT 1";
-
$result = mysql_query($sql);
-
-
// Make sure the SQL query was successful
-
if($result) {
-
echo "Updated!";
-
}
-
else {
-
echo "Error! " . mysql_error();
-
}
-
}
-
else
-
{
-
// Get and "id" from the URL, or default to 1
-
($id = @$_GET['id']) or $id = 1;
-
-
// Fetch values
-
$sql = "SELECT `value1`, `value2`
-
FROM `table`
-
WHERE `id` = $id";
-
$result = mysql_query($sql) or die("Failed to fetch values. " . mysql_error());
-
$row = mysql_fetch_assoc($result);
-
-
// Prepare values for being printed into HTML
-
$oldValue1 = htmlentities($row['value1'], ENT_QUOTES, 'UTF-8');
-
$oldValue2 = htmlentities($row['value2'], ENT_QUOTES, 'UTF-8');
-
-
// Print the HTML
-
echo <<<HTML
-
<form action="{$_SERVER['PHP_SELF']}" method="post">
-
<input type="hidden" name="id" value="{$id}">
-
Value1: <input type="text" name="newValue1" value="{$oldValue1}"><br>
-
Value2: <input type="text" name="newValue2" value="{$oldValue2}"><br>
-
<input type="submit" value="Update">
-
</form>
-
HTML;
-
-
}
-
?>
I did what you said, and it's still having problems updating :(
This is how my script looks now: -
-
<html>
-
<?
-
-
if(isset($ud_ID,$ud_Client, $ud_Number,$ud_Address,$ud_Issue,$ud_Notes,$ud_Status,$ud_Charge)){
-
-
//Update
-
$ud_ID=$_POST['ud_ID'];
-
$ud_Client=$_POST['ud_Client'];
-
$ud_Number=$_POST['ud_Number'];
-
$ud_Address=$_POST['ud_Address'];
-
$ud_Issue=$_POST['ud_Issue'];
-
$ud_Notes=$_POST['ud_Notes'];
-
$ud_Status=$_POST['ud_Status'];
-
$ud_Charge=$_POST['ud_Charge'];
-
-
$query="UPDATE inprogress SET Time=NOW(),Client='$ud_Cleint',Number='$ud_Number',Address='$ud_Address',Issue='$ud_Issue',Notes='$ud_Notes,Status='ud_Status',Charge='$ud_Charge' WHERE ID='$ID' LIMIT 1 ";
-
-
-
mysql_query("$query");
-
}
-
-
else{
-
$ID=$_GET['ID'];
-
$username="*************";
-
$password="**************";
-
$database="***************";
-
mysql_connect("**************",$username,$password);
-
mysql_select_db($database);
-
$query="SELECT* FROM inprogress ";
-
$result=mysql_query($query);
-
-
-
//Print output
-
$row=mysql_fetch_assoc($result);
-
-
$ID=$row['ID'];
-
$Time=$row['Time'];
-
$Client=$row['Client'];
-
$Number=$row['Number'];
-
$Address=$row['Address'];
-
$Issue=$row['Issue'];
-
$Notes=$row['Notes'];
-
$Status=$row['Status'];
-
$Charge=$row['Charge'];
-
}
-
?>
-
-
-
<form method="POST">
-
<input type="hidden" name="ud_ID" value="<? echo $ID; ?>">
-
Client: <input type="text" name="ud_Client" value="<? echo $Client; ?>"><br>
-
Address: <input type="text" name="ud_Address" value="<? echo $Address; ?>"><br>
-
Number: <input type="bigint(20)" name="ud_Number" value="<? echo $Number; ?>"><br>
-
Issue: <input type="longtext" name="ud_Issue" value="<? echo $Issue; ?>"><br>
-
Notes: <input type="longtext" name="ud_Notes" value="<? echo $Notes; ?>"><br>
-
Status: <input type="tinyint(1)" name="ud_Status" value="<? echo $Status; ?>"><br>
-
Charge: <input type="double" name="ud_Charge" value="<? echo $Charge; ?>"><br>
-
<input type="Submit" value="Update">
-
</form>
-
-
<input type="Submit" onClick="window.close()" value="Close Window">
-
-
<?
-
-
-
-
-
//mysql_close();
-
-
?>
-
-
-
</html>
-
-
Also, when would I use a "@" and I recently bought an SSL, so would that effect anything with how the script works?
Atli 5,058
Expert 4TB
Your code is not structured correctly. This is the basic idea of what you should be doing: - if ( the data has been posted ) {
-
fetch the posted data,
-
create the UPDATE query,
-
and execute the query.
-
}
-
ELSE {
-
fetch an ID from the URL or use 1 if there is no ID in the URL
-
fetch the row data from MySQL
-
insert the data into the HTML form and print it
-
}
There are a number of problems in your code: - The isset() clause at the beggining is meant to test for the existence of the $_POST elements, not the local variables you later create to hold the data. (See how I use it in my earlier example.)
- You are using the wrong $ID in the update query. That variable doesn't exists in that part of the code. You should be using the $ud_ID created in the lines preceding the UPDATE query.
- When you execute the UPDATE query, you have not yet opened a connection to MySQL. - You have to open a MySQL before using any of the MySQL functions. Doing it later, in another part of the code, will not work.
- The SELECT query does not have a WHERE clause, so it will always fetch ALL the data in the table. You need to add a WHERE clause to fetch only the ID of the row you want to edit. (See my earlier example.)
- The HTML for the form is outside the IF... ELSE structure, so it will show regardless of whether or not the UPDATE query is executed. - If you want this to be the case, you also need to put the SELECT outside the ELSE clause, or you will get an empty form after you submit it.
Also, when would I use a "@" and I recently bought an SSL, so would that effect anything with how the script works?
From PHP's perspective a SSL request is no different from a normal request, except for the URL using a "https" prefix rather than "http".
The @ char is used in PHP to silence errors. You don't really need to use it, but it can be handy when you know an error may occur and that it will have no effect on your code. (Or even be a normal part of the code's function.)
Like in my example earlier, when I do: - ($id = @$_GET['id']) or $id = 1;
the part inside the parenthesis tries to fetch an "id" from the URL and assign it to $id. If there is no "id" in the URL, $id will be NULL and the "or" will catch that and set the $id to 1. -- It's basically: "Set $id as the 'id' from the URL, or 1 of there is no 'id' in the URL".
The @ is there because if there is no "id" in the URL, the attempt to fetch it would generate an "undefined index" warning, but because I know it may happen and I have already written in a fail-safe for it, I use @ to silence the warning.
-
-
<?
-
-
if(isset($_POST['ID'],$_POST['ud_Client'], $_POST['ud_Number'],$_POST['ud_Address'],$_POST['ud_Issue'],$_POST['ud_Notes'],$_POST['ud_Status'],$_POST['ud_Charge'])){
-
-
//Update
-
$ud_ID=mysql_real_escape_string($_POST['ud_ID']);
-
$ud_Client=mysql_real_escape_string($_POST['ud_Client']);
-
$ud_Number=mysql_real_escape_string($_POST['ud_Number']);
-
$ud_Address=mysql_real_escape_string($_POST['ud_Address']);
-
$ud_Issue=mysql_real_escape_string($_POST['ud_Issue']);
-
$ud_Notes=mysql_real_escape_string($_POST['ud_Notes']);
-
$ud_Status=mysql_real_escape_string($_POST['ud_Status']);
-
$ud_Charge=mysql_real_escape_string($_POST['ud_Charge']);
-
//16
-
$query="UPDATE inprogress SET Time=NOW(),Client='$ud_Cleint',Number='$ud_Number',Address='$ud_Address',Issue='$ud_Issue',Notes='$ud_Notes,Status='ud_Status',Charge='$ud_Charge' WHERE ID='$ud_ID' LIMIT 1 ";
-
-
$username="";
-
$password="";
-
$database="";
-
mysql_connect("",$username,$password);
-
mysql_select_db($database);
-
$query="SELECT* FROM inprogress ";
-
$result=mysql_query($query);
-
//28
-
mysql_query("$query");
-
}
-
-
else{
-
-
$ID=@$_GET['ID'] or $ID=1;
-
$username="";
-
$password="";
-
$database="";
-
mysql_connect("",$username,$password);
-
mysql_select_db($database);
-
$query="SELECT* FROM inprogress WHERE ID=$ID ";
-
$result=mysql_query($query);
-
-
$row=mysql_fetch_assoc($result);
-
-
$Client = htmlentities($row['Client'], ENT_QUOTES, 'UTF-8');
-
$Address = htmlentities($row['Address'], ENT_QUOTES, 'UTF-8');
-
$Number = htmlentities($row['Number'], ENT_QUOTES, 'UTF-8');
-
$Isse = htmlentities($row['Issue'], ENT_QUOTES, 'UTF-8');
-
$Notes = htmlentities($row['Notes'], ENT_QUOTES, 'UTF-8');
-
$Charge = htmlentities($row['Charge'], ENT_QUOTES, 'UTF-8');
-
$Status = htmlentities($row['Status'], ENT_QUOTES, 'UTF-8');
-
-
echo <<<HTML;
-
-
<form action="{$_SERVER['PHP_SELF']}" method="POST">
-
<input type="hidden" name="ud_ID" value="<? echo $ID; ?>">
-
Client: <input type="text" name="ud_Client" value="<? echo $Client; ?>"><br>
-
Address: <input type="text" name="ud_Address" value="<? echo $Address; ?>"><br>
-
Number: <input type="bigint(20)" name="ud_Number" value="<? echo $Number; ?>"><br>
-
Issue: <input type="longtext" name="ud_Issue" value="<? echo $Issue; ?>"><br>
-
Notes: <input type="longtext" name="ud_Notes" value="<? echo $Notes; ?>"><br>
-
Status: <input type="tinyint(1)" name="ud_Status" value="<? echo $Status; ?>"><br>
-
Charge: <input type="double" name="ud_Charge" value="<? echo $Charge; ?>"><br>
-
<input type="Submit" value="Update">
-
</form>
-
-
-
//<input type="Submit" onClick="window.close()" value="Close Window">
-
-
HTML;
-
-
}
-
-
?>
-
This give me an error. What did I do wrong?
Atli 5,058
Expert 4TB
Line #49. The semi-colon following the HTML can't be there. Nothing can follow the delimiter ("HTML", in your case) and the delimiter must only contain characters that would be valid for a variable name. (This also includes white-spaces, by the way. - A common error when using heredoc syntax.)
Also, inside the HTML (between #49 and #64) the "<?php echo ...; ?>" need to be replaced by "{...}". - When used like that, the HTML is a string, so you just add the variables to it like you would a normal string. For example, line #54 should be: - Client: <input type="text" name="ud_Client" value="{$Client}"><br>
And you need to remove or relocate the comment on line #65 outside the "<<<HTML ... HTML;" delimiters. (Or it will be printed to the HTML as-is.)
I changed it, but now it's saying that the fetch isn't valid on line 39.... WTF? -
<?
-
-
if(isset($_POST['ID'],$_POST['ud_Client'], $_POST['ud_Number'],$_POST['ud_Address'],$_POST['ud_Issue'],$_POST['ud_Notes'],$_POST['ud_Status'],$_POST['ud_Charge'])){
-
-
//Update
-
$ud_ID=mysql_real_escape_string($_POST['ud_ID']);
-
$ud_Client=mysql_real_escape_string($_POST['ud_Client']);
-
$ud_Number=mysql_real_escape_string($_POST['ud_Number']);
-
$ud_Address=mysql_real_escape_string($_POST['ud_Address']);
-
$ud_Issue=mysql_real_escape_string($_POST['ud_Issue']);
-
$ud_Notes=mysql_real_escape_string($_POST['ud_Notes']);
-
$ud_Status=mysql_real_escape_string($_POST['ud_Status']);
-
$ud_Charge=mysql_real_escape_string($_POST['ud_Charge']);
-
-
$query="UPDATE inprogress SET Time=NOW(),Client='$ud_Cleint',Number='$ud_Number',Address='$ud_Address',Issue='$ud_Issue',Notes='$ud_Notes,Status='ud_Status',Charge='$ud_Charge' WHERE ID='$ud_ID' LIMIT 1 ";
-
-
$username="";
-
$password="";
-
$database="";
-
mysql_connect("",$username,$password);
-
mysql_select_db($database);
-
$query="SELECT* FROM inprogress WHERE ID=$ID";
-
$result=mysql_query($query);
-
-
mysql_query($query);
-
}
-
-
else{
-
-
$ID=@$_GET['ID'] or $ID=1;
-
$username="";
-
$password="";
-
$database="";
-
mysql_connect("",$username,$password);
-
//mysql_select_db($database);
-
$query="SELECT* FROM gancsosa_crystalworks.inprogress WHERE ID=$ID ";
-
$result=mysql_query($query);
-
-
$row=mysql_fetch_assoc($result);
-
-
$Client = htmlentities($row['Client'], ENT_QUOTES, 'UTF-8');
-
$Address = htmlentities($row['Address'], ENT_QUOTES, 'UTF-8');
-
$Number = htmlentities($row['Number'], ENT_QUOTES, 'UTF-8');
-
$Isse = htmlentities($row['Issue'], ENT_QUOTES, 'UTF-8');
-
$Notes = htmlentities($row['Notes'], ENT_QUOTES, 'UTF-8');
-
$Charge = htmlentities($row['Charge'], ENT_QUOTES, 'UTF-8');
-
$Status = htmlentities($row['Status'], ENT_QUOTES, 'UTF-8');
-
-
echo <<<HTML
-
-
<form action="{$_SERVER['PHP_SELF']}" method="POST">
-
<input type="hidden" name="ud_ID" value="{$ID}">
-
Client: <input type="text" name="ud_Client" value="{$Client}"><br>
-
Address: <input type="text" name="ud_Address" value="{$Address}"<br>
-
Number: <input type="bigint(20)" name="ud_Number" value="{$Number}"><br>
-
Issue: <input type="longtext" name="ud_Issue" value="{$Issue}"><br>
-
Notes: <input type="longtext" name="ud_Notes" value="{$Notes}"><br>
-
Status: <input type="tinyint(1)" name="ud_Status" value="{$Status}"><br>
-
Charge: <input type="double" name="ud_Charge" value="{$Charge}"><br>
-
<input type="Submit" value="Update">
-
</form>
-
-
-
<input type="Submit" onClick="window.close()" value="Close Window">
-
-
HTML;
-
-
}
-
-
?>
-
123456789123456789123456789
i went back to pure php since the embedded html was getting me confused and now it's working.
I just need to get the script to work as a loop again
any ideas how i can do that?
-
-
Print '<th><a href="https://www.1fixcomputermedic.com/update.php?id " target="_blank">Edit</a></th>';
-
-
any ideas why this doesn't bring in id as a variable?
Atli 5,058
Expert 4TB
The "id" in the URL of that link has no value. Where is the value supposed to be coming from?
-
-
$id="_GET['ID']";
-
-
while($info = mysql_fetch_array( $data ))
-
{
-
-
Print "<tr>";
-
Print "<th>ID: ".$info['ID'] . "</th> ";
-
Print "<th>Time: " .$info['Time'] . "</th>";
-
Print "<th>Name: ".$info['Client'] . " </th>";
-
Print "<th>Number: " .$info['Number'] . "</th>";
-
Print "<th>Address: " .$info['Address'] . "</th>";
-
Print "<th>Issue: " .$info['Issue'] . "</th>";
-
Print "<th>Notes: " . $info['Notes'] . "</th>";
-
Print "<th>Status: " .$info['Status'] . "</th>";
-
Print "<th>Charge: $" .$info['Charge'] . "</th>";
-
Print '<th><a href="https://www.1fixcomputermedic.com/update.php?ID="$id" " target="_blank">Edit</a></th>';
-
Print '<th><a href="" target="_blank">Print</a></th>';
-
Print "</tr>";
-
-
}
-
Atli 5,058
Expert 4TB
Ok. If you want the link to include the ID, you need to put the ID into the URL, in the same way you do with the lines above it. - The links should look like: http://example.com/page.php?name=value where "name" is the name of the variable you want to pass ("id" in your case) and "value" is the value of it. - Your URL is just missing the "value" part.
is there some way i can make the value part a variable as in so that i can put it into a loop?
Atli 5,058
Expert 4TB
Explain this looping a little better.
Do you want to display multiple values on a single page, or do you want to do something like... updating one row, and be automatically sent to the next row when done?
P.S. - $id="_GET['ID']";
-
// Should be
-
$id=$_GET['ID'];
See Strings and Superglobals in the manual.
this is where i print out my data, well, at least my inprogress data.
then i have a link for the update page, which i'm having trouble with.
after the data has been updated, i have a script where it puts it into the correct table.
i want the link to have a variable instead of having ?id=1, instead, i want to make it something like ?ID=$id, where $id is the id of the row, which i will be updating. in other words, it should be a link to the unique update page.
Question:
login.php-login information
checklogin.php:
{ retrieve cookie if possible
else
set cookie
}
update.php
the action for the form is set to go back to checklogin.php, but it doesn't save the username and password. why would that be? ALSO
i still need help making that id link compatible with my loop in the script. any help would be greatly appreciated.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: jimb |
last post by:
I need some advice on how to securely transfer data between two servers.
Here is the situation. We have two sql servers that hold student data.
I...
|
by: phong.lee |
last post by:
Hello all, i'm new at this. I need some assistant in transferring data
from excel to access.
I created a macro that basically gather all the...
|
by: Rani |
last post by:
hi guys I don't know if this is the right place for it but
I created 2 pages
in page one there is a text box in which the user enters his name,
in...
|
by: http://www.visual-basic-data-mining.net/forum |
last post by:
Does anyone have any idea how to transferring data from TextBox1 in form1 to
textBox2 in form2.....
That means after i fill in any data in...
|
by: neilr |
last post by:
Can anyone help with some problkems that have wasted 2 days of my
(inexperienced) time already?
We have a website which allows people to register...
|
by: meetalps |
last post by:
Hi All,
Can you please help me with a step by step procedure to transfer files
from my PC to DB2-AIX and vice versa. I am new to both.
Example...
|
by: ControlHead |
last post by:
Hello All,
I have a tricky problem. I have two forms in MS Access where the user enters information.
The first form links to a table with only...
|
by: cbs81 |
last post by:
hi all,
problem:
transferring data from workbooks that are stored in a particular directory from excel to a table in access. when done, the...
|
by: OuTCasT |
last post by:
I have a table on one server and another on another server.
I transfferred that data from the old table to the new table but some of the data...
|
by: angusfreefa |
last post by:
Dear All,
I am facing a problem of transferring data between 2 tables within the same database.
I set up 2 tables. The first table is the...
|
by: tammygombez |
last post by:
Hey fellow JavaFX developers,
I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
|
by: tammygombez |
last post by:
Hey everyone!
I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
|
by: concettolabs |
last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
|
by: CD Tom |
last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
| |