View Full Version : Very easy PHP / Mysql Problem..
Spherian
09-05-2002, 04:57 PM
Hello..
Firstly can i say sorry for asking for help on my first post. ;)
Okay, I need a few examples of how to display information from a mysql database, if any one has the time.. Here is my query in more detail.
I know how to connect to the database (Thats about it) So i am now connected, There are 7 fields, and one of the fields is "Reports" I want to display on screen the all the details of the row IF Reports has a value of 1 or more.
Hmm.. Confused...
Any comments would be appreciated.
^BuGs^
09-05-2002, 05:13 PM
$array = mysql_query("SELECT * FROM TABLENAMEHERE WHERE SOMETHING ARGUMENT VALUE");
while ($i=mysql_fetch_array($array)) {
/* do what in here
vars returned are: $i[nameoffield]; */
}
Spherian
09-05-2002, 05:49 PM
Would this be valid
$array = mysql_query("SELECT * FROM xlinks WHERE reports > 0 ");
?? Basically, show all that are more than 0.
Halide
09-05-2002, 06:01 PM
I would use $result instead of $array
:)
and it looks ok to me...
Halide
09-05-2002, 06:07 PM
im going to qbasic class :D later
Spherian
09-05-2002, 06:10 PM
Hey people, I am getting this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /usr/local/psa/home/vhosts/httpdocs/new/reported2.php on line 24
This is the bottm piece of script:
$conn = @MYSQL_CONNECT($server, $user, $pass);
//Select DB
@MYSQL_SELECT_DB($mydb) or die ("<h1>Database '$mydb' does not exist or mySQL is not connected!
Please check your settings ...</h1>");
//Check
if(!$conn) die("<h1>mySQL-Connection-Error
Check your settings ...</</h1>");
$result = mysql_query("SELECT * FROM l_xlinks WHERE reports >0");
while ($i=mysql_fetch_array($result)) {
echo("$i[name]");
}
?>
Hmm, i dont mean to be a pest, but any info would be great, also i am very new to Mysql. So b gental.. :)
Halide
09-05-2002, 06:13 PM
If you want a good reference, check out the HUGE documentation that they have.
Also, what line is 24 in your script? What editor are you using?
Halide
09-05-2002, 06:15 PM
I gotta go.. bbl
Spherian
09-05-2002, 06:17 PM
line 24 is this:
while ($i=mysql_fetch_array($result)) {
I will have a read up now. :)
^BuGs^
09-05-2002, 06:49 PM
$result = mysql_query("SELECT * FROM l_xlinks WHERE reports > 0");
roninblade
09-05-2002, 11:25 PM
... and try printing out mysql_error()
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.