473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

PHP help needed.

I have a section of code that seems to work untill I go to get the result but can't see what I am doing wrong.

Expand|Select|Wrap|Line Numbers
  1. function Edit_User(){
  2.  
  3. global $conn;
  4. Connect_to_db();
  5.  
  6. $sql = "SELECT * FROM user";
  7. $result = mysql_query($sql, $conn) or die(mysql_error());
  8.  
  9. ?>
  10. <form method="post" action="../news/news.php?page=Edit_Selected_User" name="EditUser">
  11. <select name="selectuser">
  12. <?php
  13.  
  14. while ($newArray = mysql_fetch_array($result)){
  15.  
  16.   $editname = $newArray['name'];
  17.   printf ("<option value=\"$result\">$editname</option>");
  18. }
  19. ?>
  20. </select>
  21. <input type="submit" name="edit" value="Edit">
  22. </form>
  23. <?php
  24.  
  25. mysql_close();
  26. }
The above part seems to work however when I try to get the data returned from the $_POST it's always blank.

Expand|Select|Wrap|Line Numbers
  1. if ($_GET[page] == "Login"){
  2.   Get_Login_Page();
  3. }
  4. else if($_GET[page] == "Edit_Selected_User"){
  5.  $a = $_Post[selectuser];
  6.  echo $a;                        //  This always returns nothing.
  7. else if($_GET[page] == "Edit_User"){
  8.   Edit_User();
  9. }
  10. else if($_GET[page] == "Adduser"){
  11.   Add_User_Menu();
  12. }
  13. else if($_GET[page] == "Save_New_User"){
  14.   Save_New_User();
  15. } else {
  16.   echo "Nothing to do!";
  17. }
I know I am just doing something stupid wrong but can't seem to find out what.
May 3 '06 #1
3 1529
I found the error here

$a = $_Post[selectuser];

Should be:

$a = $_POST[selectuser];

It's still not quite working the way I wanted it to because it returns the resource ID instead of a user name but I will try to play with it more and see if I can figure that one out.
May 3 '06 #2
I also got the resource ID problem figured out. Guess I didn't need help afterall. Just needed a break from coding. lol
May 3 '06 #3
Banfa
9,065 Expert Mod 8TB
$a = $_POST[selectuser];
If selectuser is a string it is safer to write this as[php]$a = $_POST['selectuser'];[/php]NOTE the added quotes. This is because without the quotes the PHP engine first searchs to see if selectuser is a defined symbol.
May 3 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: System | last post by:
Hello All, Redhat 9.0 Mysql 3.23.56 ==> Running I want to upgarde to 4.0.13 but this is the error it says: # rpm -Uvh MySQL-server-4.0.13-0.i386.rpm warning: MySQL-server-4.0.13-0.i386.rpm: V3...
8
by: Stephen | last post by:
I am trying to add some code to below to include a datatable and fill the datatable. The reason for doing this is so as I can check to see whether there are any rows returned by the stored...
13
by: Joe Feldman | last post by:
This position is located in the South Bay Area in Northern California. If you are interested please send me your resume in a word .doc so that I can review it. If this does not look like a match,...
0
by: Cindy B | last post by:
Please send your resume and position to Cindy@AtlanticResource.com! I CAN NOT accept candidates that ARE OUTSIDE OF THE US! NO PHONE CALLS PLEASE! Email your resume to me! Position:SQL...
3
by: Wade | last post by:
I would like to install the .Net 1.1 framework on a Web Server running W2K to be able to run ASP.NET files, but I'm not sure where to find the files I need for the .Net framework. I have ".NET...
17
by: dingoatemydonut | last post by:
The C99 standard states: "In the abstract machine, all expressions are evaluated as specified by the semantics. An actual implementation need not evaluate part of an expression if it can deduce...
5
by: Steve | last post by:
Hi, I am sitting down to design our next set of internal apps. I would like to approach this in a way that would allow me to break logical parts of the application that handle specific tasks...
0
by: ultradiv | last post by:
I have a VB.NET application partly built that produces an xml output (just a file at present) I have a .NET webserver and SQLserver 2000 I need to be able to send the xml to the webserver/database...
28
by: Ian Davies | last post by:
Hello I would appreciate some help from someone who has knowledge of working with css, php javascript and how they interact. Ive been working on a task for the last few days and have started to...
37
by: C_guy | last post by:
Does anyone know of a (hopefully free) tool that can traverse a project and determine which "#include"s are not needed or needed in every .C file? This would be helpful in removing header...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.