sql connect help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

rodrigorules
Forum Commoner
Posts: 35
Joined: Wed Jan 05, 2005 3:10 pm

Post by rodrigorules »

Warning: odbc_exec(): SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near 'LIMIT'., SQL state 37000 in SQLExecDirect in c:\appserv\www\ranking.php on line 6
Error in SQL

yikes error, didnt work
Last edited by rodrigorules on Wed Jan 05, 2005 8:34 pm, edited 1 time in total.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I believe DESC goes last... not to good with SQL
rodrigorules
Forum Commoner
Posts: 35
Joined: Wed Jan 05, 2005 3:10 pm

Post by rodrigorules »

Code: Select all

$sql="SELECT * FROM character WHERE CtlCode IS NULL ORDER LIMIT 35 BY cLevel DESC";
no that still doesnt work =/
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

not what I meant...

Code: Select all

<?php
$sql="SELECT * FROM character WHERE CtlCode IS NULL ORDER BY cLevel LIMIT 35 DESC";
?>
rodrigorules
Forum Commoner
Posts: 35
Joined: Wed Jan 05, 2005 3:10 pm

Post by rodrigorules »

Warning: odbc_exec(): SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near 'LIMIT'., SQL state 37000 in SQLExecDirect in c:\appserv\www\ranking.php.php on line 7
Error in SQL

yea i changed to the one u posted above this post
and i still get error, weird =/
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

i'm not sure then, I'm not too familar with sql syntax and I'm not on my work computer so I can't refer to it.
rodrigorules
Forum Commoner
Posts: 35
Joined: Wed Jan 05, 2005 3:10 pm

Post by rodrigorules »

icic , thanks for helping :D
ill try to look it up in that guide u posted.. 8O

EDIT: i tried MAX_ROWS but didnt work also..
anyone with soltuon? :o
rodrigorules
Forum Commoner
Posts: 35
Joined: Wed Jan 05, 2005 3:10 pm

Post by rodrigorules »

http://us3.php.net/odbc_fetch_row
look...i know this is it but how would i use it?

Code: Select all

while (odbc_fetch_row($rs,35))
didnt work, as it said it would (it gets row 35, unlimited times)

-------

Code: Select all

while (odbc_fetch_row($rs, $i=1, $i<35, i++))
some parse error =/
------
thats all i could think of...anybody think they know?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

from a quick google prayer:

Code: Select all

SELECT TOP 35 * FROM character WHERE CtlCode IS NULL ORDER BY cLevel DESC
rodrigorules
Forum Commoner
Posts: 35
Joined: Wed Jan 05, 2005 3:10 pm

Post by rodrigorules »

THanks :D :D


EDIT!! : i had to change the database and now i need help getting this to work...

Code: Select all

<html><center><body background="b.jpg"><?php
$conn=odbc_connect('MuOnline','',''); 
if (!$conn)
{
exit("Connection Failed: " . $conn); 
} 


$sql="SELECT TOP 35 * FROM character WHERE CtlCode IS NULL ORDER BY cLevel DESC";
 $rs=odbc_exec($conn,$sql); 
if (!$rs)
{ 
exit("Error in SQL");
} 
echo "<table border=1><tr>";echo "<th>Name</th>";
echo "<th>Level</th>";
echo "<th>Money</th>";
echo "<th>Experiance</th>";
echo "<th>Strength</th>";
echo "<th>Agility</th>";
echo "<th>Vitality</th>";
echo "<th>Energy</th>";
echo "<th>Resets</th></tr>";
while (odbc_fetch_row($rs))


{
$resets=odbc_result($rs, "Resets");
$xp=odbc_result($rs,"Experience");
$str=odbc_result($rs,"Strength");
$agi=odbc_result($rs,"Dexterity");
$vit=odbc_result($rs,"Vitality");
$nrg=odbc_result($rs,"Energy");
$zen=odbc_result($rs,"Money");
$pname=odbc_result($rs,"Name");
$level=odbc_result($rs,"cLevel");
echo "<tr><td>$pname</td>";
echo "<td>$level</td>";
echo "<td>$zen</td>";
echo "<td>$xp</td>";
echo "<td>$str</td>";
echo "<td>$agi</td>";
echo "<td>$vit</td>";
echo "<td>$nrg</td>";
echo "<td>$resets</td></tr>";
}
odbc_close($conn);
echo "</table>";




?></body></html>
i need to make the column Resets connect to the table "MEMB_INFO"
instead of "character" but still be in the same table?
please reply someone, i planned to open my server now..heh cant do it now

well if someone can reply it would be helpful :)
rodrigorules
Forum Commoner
Posts: 35
Joined: Wed Jan 05, 2005 3:10 pm

Post by rodrigorules »

please help, bump, i need help again -_- read above post
k thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I don't quite understand what you are wanting to do now. How is the column Resets supposed to connect to the table MEMB_INFO ?
rodrigorules
Forum Commoner
Posts: 35
Joined: Wed Jan 05, 2005 3:10 pm

Post by rodrigorules »

what i mean is that
the Resets column is in the MEMB_info

and i want it to show up here in the TABLE, but the $SQL says to check for table "character"
what do i do so it checks MEMB_INFO so the column "resets" which is in MEMB_INFO
can be in the table
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you'll need a way for them to link together, or you'll get multple ~duplicate rows. Anyways, I haven't the energy to sift through the google prayer: [google]mssql +join[/google]. As you may guess, it involves a join of some sort.
rodrigorules
Forum Commoner
Posts: 35
Joined: Wed Jan 05, 2005 3:10 pm

Post by rodrigorules »

o god thats confusing..i think ill just make a serperate table then :(
Post Reply