Hi,
I'm not sure what were you trying to do but there are some very obvious
errors

1. You cannot embed one php openning tag (<?) in another
2. mysql_numrows() is not a valid mysql function - may be you were trying to
use mysql_num_rows()

If you are trying to put all fields my_name into the $WELCOME variable (I
can't think of a reason to do this) and then echo it may be you could use
this code

#start code
<?
$link = mysql_connect("localhost","username","password") or die ("Could not
connect to MySQL!");
mysql_select_db("database",$link);
$result = mysql_query("select * from table_name);
while ($row=mysql_fetch_array($result)){
    $WELCOME.=$row["my_name"];
}
echo $WELCOME;
?>
#end code

Dobromir Velev


-----Original Message-----
From: Matt Nigh <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Monday, July 02, 2001 1:01 AM
Subject: [PHP-DB] define variable by querying MySQL


hello list. i have a problem that is relatively simple, but I can't seem to
figure it out.
is there any way to define a variable by querying a MySQL database?
here's an example of code I tried using:

----------------------------------------------------------------
<?
$WELCOME = "
echo "<?php
$link = mysql_connect("localhost","username","password");
if(!$link) die ("Could not connect to MySQL!");
mysql_select_db("database",$link);
$result = mysql_query("select * from table_name);
$num=mysql_numrows($result);
for($x=0;$x<$num;$x++) {
$row=mysql_fetch_object($result);
print "$row->my_name";
}
mysql_close($link);
?>
";
";
?>

<? echo($WELCOME); ?>

----------------------------------------------------------------



it kept coming up with the following :

----------------------------------------------------------------
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or
`T_NUM_STRING' in c:\apache group\apache\htdocs\page.php on line 5
----------------------------------------------------------------


i can't figure out what to do, so if anyone can assist me, i'd be greatful.
I have a feeling it's something with some quotes but i can't figure out
which ones.


Thanks a lot,


Matt Nigh
[EMAIL PROTECTED]








-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to