That's unusual; you shouldn't be getting a query is empty from this.
You should be able to verify this by modifying this: $result = mysql_query($order); to this: $result = mysql_query($order) or die('Failed to execute query: ' . $order . ', error: ' . mysql_error());. I'm not going to lie, I'm not convinced that the problem is here.
Edit:
BTW, if you don't see that error string in the die, then the problem is not here. If you do, post that in its entirety.
That's unusual; you shouldn't be getting a query is empty from this.
You should be able to verify this by modifying this: $result = mysql_query($order); to this: $result = mysql_query($order) or die('Failed to execute query: ' . $order . ', error: ' . mysql_error());. I'm not going to lie, I'm not convinced that the problem is here.
Edit:
BTW, if you don't see that error string in the die, then the problem is not here. If you do, post that in its entirety.
Hello,
No error the script runs but the textboxes don't contain the information they are supposed to hmm (
Perhaps the fact that i'm using ID?
The best I can get is the boxes all filled but with the first users data
That was
I wouldn't expect that error from it, but $id isn't defined anywhere in the script. So you are effectively pointing at id = null (where null isn't the same as IS NULL in SQL). Since no id will match null, there is therefore no results.
Perhaps the id should be coming from $_GET? $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; for example?
I wouldn't expect that error from it, but $id isn't defined anywhere in the script. So you are effectively pointing at id = null (where null isn't the same as IS NULL in SQL). Since no id will match null, there is therefore no results.
Perhaps the id should be coming from $_GET? $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; for example?
This error indicates you have no field named "name".
Although you'll still have an issue. $_GET['id'] is reporting nothing on your query. That may not be a problem though; if that comes from a form its very often $_POST not get.
This error indicates you have no field named "name".
Although you'll still have an issue. $_GET['id'] is reporting nothing on your query. That may not be a problem though; if that comes from a form its very often $_POST not get.
I actually added the GET bit in Il have a test around with it.
Where have you declared the $username and $email variables? Its not that its deleted, its that you have not provided it with valid variables.
You need to look into how to handle input from a form: $_GET or $_POST as appropriate, and how to secure that SQL from injection. You should look at prepared statements for this as the mysql library is quite old and recommended it not be used (I expect it'll be deprecated in the very near future).
Where have you declared the $username and $email variables? Its not that its deleted, its that you have not provided it with valid variables.
You need to look into how to handle input from a form: $_GET or $_POST as appropriate, and how to secure that SQL from injection. You should look at prepared statements for this as the mysql library is quite old and recommended it not be used (I expect it'll be deprecated in the very near future).
Hello it should be using the textboxes infomation
I want it to use the infomation in the two textboxes email and username
On the html they are called email and username also exactly grrrrrrr
I know where its coming from; PHP does not know. You must pull it from a superglobal such as $_POST. The only time you can not declare them is if register_globals is enabled (disabled by default as of PHP 4.2; gone as of 5.4), so you should never rely on register_globals existing. You must pull from the appropriate input from the $_GET or $_POST whichever is providing the data.
I know where its coming from; PHP does not know. You must pull it from a superglobal such as $_POST. The only time you can not declare them is if register_globals is enabled (disabled by default as of PHP 4.2; gone as of 5.4), so you should never rely on register_globals existing. You must pull from the appropriate input from the $_GET or $_POST whichever is providing the data.
Im sorry I dont really understand what you wrote there
Is there no easy way of referencing it to the text boxes and I need this to be able to edit any user I wish
Sure there is, its under $_POST['inputNameHere']. Just like the code I posted for the id, which would come from the $_GET or default to 0 if it doesn't exist.
Sure there is, its under $_POST['inputNameHere']. Just like the code I posted for the id, which would come from the $_GET or default to 0 if it doesn't exist.
So your saying
Code:
<?
//edit_data.php
include "db.inc.php";
$id = $_POST["email"]; - something like this? How would I reference everything else then
$order = "UPDATE members
SET username='$username',
email='$email'
WHERE
id='$id'";
$result = mysql_query($order) or die('Failed to execute query: ' . $order . ', error: ' . mysql_error());
header("location:edit.php");
?>
OR
Code:
<?
//edit_data.php
include "db.inc.php";
$id = isset($_POST['id']) ? (int)$_POST['id'] : 0;
$order = "UPDATE members
SET username='$username',
email='$email'
WHERE
id='$id'";
$result = mysql_query($order) or die('Failed to execute query: ' . $order . ', error: ' . mysql_error());
header("location:edit.php");
?>
OR
Code:
<?
//edit_data.php
include "db.inc.php";
$email = $_POST["email"];
$username= isset($_POST['username']) ? (int)$_POST['username'] : 0;
$id = isset($_POST['id']) ? (int)$_POST['id'] : 0;
$order = "UPDATE members
SET username='$username',
email='$email'
WHERE
id='$id'";
$result = mysql_query($order) or die('Failed to execute query: ' . $order . ', error: ' . mysql_error());
//header("location:edit.php");
?>