Solved

results from db

Posted on 2000-04-04
6
159 Views
Last Modified: 2006-11-17
im trying to get results from database.
i want to write "good" if the $username
variable is show in the db,and "bad"
if it isn't.
here's the code:
$sql="select name,passwd from user where name=$username";
mysql_connect("haag","elad");
$result=mysql_db_query("appscan",$sql);
$row=mysql_fetch_object($result);
if ($row){
echo ("good");
}else{
echo ("bad");
}
....

it is not working...
0
Comment
Question by:eladr
  • 3
  • 3
6 Comments
 
LVL 8

Expert Comment

by:us111
Comment Utility
mysql_db_query needs 3 parameters:

int mysql_db_query(string database, string query, int [link_identifier] );

try:

$row = mysql_query($query, $sql);
0
 
LVL 8

Expert Comment

by:us111
Comment Utility
Oops other mistakes

$sql="select name,passwd from user where name=$username";
$conn = mysql_connect("database", "login", "password");
$result=mysql_query($sql, $conn);

$row=mysql_fetch_row($result);
if ($row){
     echo ("good");
}else{
     echo ("bad");
}
0
 
LVL 1

Author Comment

by:eladr
Comment Utility
not working...
where im "telling" what is the database name?
sorry...completley new to php.
know ASP...
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Author Comment

by:eladr
Comment Utility
that's the error:
Warning: Supplied argument is not a valid MySQL result resource in /home/elad/public_html/index.php on line 8

8 $row=mysql_fetch_row($result);
0
 
LVL 1

Author Comment

by:eladr
Comment Utility
that's the error:
Warning: Supplied argument is not a valid MySQL result resource in /home/elad/public_html/index.php on line 8

8 $row=mysql_fetch_row($result);
0
 
LVL 8

Accepted Solution

by:
us111 earned 2 total points
Comment Utility
Sorry mistake, try that:

<?
$sql="select * from table";
$conn = mysql_connect("localhost", "", "");

$result = mysql("yourdatabase",$sql,$conn);

$row=mysql_fetch_row($result);
if ($row){
        echo ("good");
}else{
        echo ("bad");
}
?>
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now