PDA

View Full Version : problem=(


sweet22
Sun 2nd Nov '03, 2:46pm
ok ive been trying to get this to work all day and i havent gotten it to work yet.

heres the link to the file: http://www.animationation.net/testin.php

im trying to extract some info from a table in a db but its not working

heres the code im using
1:<?php
2:
3:$connection= mysql_connect(localhost,username,pass);
4:$db="database"
5:mysql_select_db($db);
6:$query="SELECT * FROM xtd";
7:$info = mysql_query($db,$query,$connection);
8:while($object = mysql_fetch_object($info)){
9:$rank=$object->rank;}
10:echo"<html>";
11:echo"<body>";
12:echo"<b>$rank</b>";
13:echo"</body>";
14:echo"</html>";
15:
16:?>
i used username,pass, and database to hide my real info so dont say i should not have those there cause i know about em, but i dont get y it doesnt work. it keeps saying error on line 5

Babylon
Sun 2nd Nov '03, 2:48pm
if that's an exact copy paste...

Line 4: $db="database"
You need

$db="database";

(notice the -> ; at the end of the line )

Hope this helps :)

assassingod
Sun 2nd Nov '03, 2:48pm
Line 4, you've missed an ;

assassingod
Sun 2nd Nov '03, 2:49pm
doh, you beat me too it Babylon:)

sweet22
Sun 2nd Nov '03, 2:50pm
omg i missed dat lol, lets see if it works now

now im getting this:
Warning: Wrong parameter count for mysql_query() in /home/anima823/public_html/testin.php on line 7

Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/anima823/public_html/testin.php on line 8

Chroder
Sun 2nd Nov '03, 2:55pm
$info = mysql_query($db,$query,$connection);

to

$info = mysql_query($query,$connection);

No need to pass $db to it.

sweet22
Sun 2nd Nov '03, 3:01pm
ok now it says 5, hmm not exactly wut i wanted to be displayed:(

require("config.php");

if($_GET["id"]){

$query = mysql_query("SELECT * FROM $table WHERE memberid = '".$_GET["id"]."'") or die(mysql_error());
while($object = mysql_fetch_object($query)){
$rank = $object->rank;

$days = $object->date;
$days = explode(" | ",$days);

$daytoday = $days[0];
$dayplus = $days[1];
$dayplus = $dayplus + 1;

if($date != $daytoday){ $c = "UPDATE $table SET date = '$date | $dayplus' WHERE memberid = '".$_GET["id"]."'"; }
elseif($date == $daytoday) { }

if($daytoday != $date){ mysql_query($c) or die(mysql_error()); }

im trying to get multiple info from a table like this on is, one for each user registered.

Babylon
Sun 2nd Nov '03, 3:18pm
*edit* Forget it, i have no idea what's happening :D

sweet22
Sun 2nd Nov '03, 3:55pm
new problem=(
http://www.animationation.net/testin4.php

Babylon
Sun 2nd Nov '03, 3:59pm
new problem=(
http://www.animationation.net/testin4.php
Would you mind copy/pasting the whole script? :)

sweet22
Mon 3rd Nov '03, 10:33am
i fixed it