FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


php msql problem





imagefree
Its the first time i connected to mysql today, and it was sucessful, and i INSERTED the data into table successfully, but while fetching i got errors.

code is

Code:
<?php
mysql_connect('localhost', 'root');
mysql_select_db('test');

$query=
"SELECT registrant_info
FROM *
WHERE reg_id=1";
$result=mysql_query($query);
while($output=mysql_fetch_array($result))
echo "$output['reg_first']";
?>


and error is

Code:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\xampp\htdocs\database.php on line 11


when i use this code


Code:
<?php
mysql_connect('localhost', 'root');
mysql_select_db('test');

$query=
"SELECT registrant_info
FROM *
WHERE reg_id=1";
$result=mysql_query($query);
while($output=mysql_fetch_array($result))
echo "$output[0]";
?>


error come

Code:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\database.php on line 10



can you plese help me finding the problem?
the book from where i am reading, gives a similar example, but when i use this code, errors occure in all the way.
alalex
OK, the best thing to make a mysql query is to run it using phpmyadmin, and then just click on "converto to php code" then copy and paste, and you'll get the query working..

One thing that usually helps in queries, is the following:
Code:
$query= "SELECT `registrant_info` FROM * WHERE `reg_id`='1'";


I'm not sure this will correct it, but it usually helps. Wink
imagefree
same problem with this query.
kv
Code:


$query= "SELECT * FROM `registrant_info` WHERE `reg_id`='1'";

Related topics
Php, mime_content_type() problem
php security problem
PHP Login Problem
What is useful way in this php+mysql problem?
problems for indexing php pages in google.
[PHP] classes problem..
everybody has server 2 problem? [solved]
PHP variable problem
PHP OOP problem
PHP script problem
Stats problem - php execution problem (MOD Assist Required)
php mail(); problem... half fixed?
PHP noob problem
PHP Includes Problem
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.