[PHP-DB] Scriptproblem

2006-01-24 Thread Ruprecht Helms

Hi,

how can I display the stored data of an user as value in a formfield.
Actualy the formfield vorname shows no entry and the formfield name 
shows .$row-Name.


What is the correct syntax in this case.

Regards,
Ruprecht

 ?
   mysql_connect(localhost,user,password);
  $result=mysql_db_query(salzert,SELECT * FROM Benutzer WHERE ID=$id);
   echo 'input type=text name=id value=';
  echo $id;
echo '';
  echo tr;
  echotdVorname/td;
echo 'tdinput type=text name=vorname value=';
echo $row-Vorname;
echo '/td';
echo /tr;
echo tr;
echo  tdName/td;
echo 'tdinput type=text name=name value=.$row-Name./td';
echo /tr;
...
?

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Scriptproblem

2006-01-24 Thread Bastien Koert

You seem to be mixing OO and procedural coding styles...try

?
mysql_connect(localhost,user,password);
$result=mysql_db_query(salzert,SELECT * FROM Benutzer WHERE ID=$id);

$row = mysql_fetch_array($result); //get the data into an array

echo 'input type=text name=id value=';
echo $id;
echo '';
echo tr;
echo  tdVorname/td;
echo 'tdinput type=text name=vorname value=';
echo $row['Vorname'];
echo '/td';
echo /tr;
echo tr;
echo  tdName/td;
echo 'tdinput type=text name=name value=.$row['Name']./td';
echo /tr;
...
?



bastien



From: Ruprecht Helms [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: php-db@lists.php.net
Subject: [PHP-DB] Scriptproblem
Date: Tue, 24 Jan 2006 16:12:53 +0100

Hi,

how can I display the stored data of an user as value in a formfield.
Actualy the formfield vorname shows no entry and the formfield name 
shows .$row-Name.


What is the correct syntax in this case.

Regards,
Ruprecht

 ?
   mysql_connect(localhost,user,password);
  $result=mysql_db_query(salzert,SELECT * FROM Benutzer WHERE ID=$id);
   echo 'input type=text name=id value=';
  echo $id;
echo '';
  echo tr;
  echotdVorname/td;
echo 'tdinput type=text name=vorname value=';
echo $row-Vorname;
echo '/td';
echo /tr;
echo tr;
echo  tdName/td;
echo 'tdinput type=text name=name value=.$row-Name./td';
echo /tr;
...
?

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Scriptproblem

2006-01-24 Thread Balazs Hegedus
Hi,

Actually you have an undefined variable called $row which is in this
context ($row-Vorname) is an object...but $row has nor content
neither type.

I think you'd better use arrays...in this way:
(according to the PHP manual mysql_db_query() is decrepated)

?php

$link = mysql_connect(_host_, _user_, _pw_);
$db = mysql_select_db(_db_name_, $link);
$query = mysql_query(SELECT Vorname, Name FROM Benutzer WHERE ID = 
. $id, $link);
$result = mysql_fetch_assoc($query);
//and than you will get the desired values as an associative array
($result['Vorname'], $result['Name'])

?

Of course some error handling may come handy (was connect to the
database server / database selection succesful, was my query resulted
more than 0 rows or more than 1 rows or it's only produces an error
message). Check out the return values of the above functions and check
them in your script.

Hope it helped, bye:

Balazs

2006/1/24, Ruprecht Helms [EMAIL PROTECTED]:
 Hi,

 how can I display the stored data of an user as value in a formfield.
 Actualy the formfield vorname shows no entry and the formfield name
 shows .$row-Name.

 What is the correct syntax in this case.

 Regards,
 Ruprecht

   ?
 mysql_connect(localhost,user,password);
$result=mysql_db_query(salzert,SELECT * FROM Benutzer WHERE ID=$id);
 echo 'input type=text name=id value=';
echo $id;
 echo '';
echo tr;
echotdVorname/td;
 echo 'tdinput type=text name=vorname value=';
 echo $row-Vorname;
 echo '/td';
 echo /tr;
 echo tr;
 echo   tdName/td;
 echo 'tdinput type=text name=name value=.$row-Name./td';
 echo /tr;
 ...
 ?

 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php