Page 2 of 3

Posted: Sat Feb 14, 2004 1:32 pm
by Ne0
same message:
Parse error: parse error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in c:\program files\apache group\apache\htdocs\ne0\index4.php on line 6

Code: Select all

<?php
mysql_connect(localhost,"ne0","****"); 
@mysql_select_db($database) or die( "Unable to select database"); 
$result = @mysql_query ("select * from users"); 
while ($row = mysql_fetch_object ($result)) { 
print "$row["username"]; or die (mysql_error()); 
}
?>

Posted: Sat Feb 14, 2004 1:37 pm
by tim
i'm a idiot =]

Code: Select all

<?php
mysql_connect(localhost,"ne0","****"); 
@mysql_select_db($database) or die( "Unable to select database"); 
$result = @mysql_query ("select * from users"); 
while ($row = mysql_fetch_object ($result)) { 
$user = $row["username"];
echo "$user";
} 
?>
This should atleast display the user colum to just see if it works.. I wish I had a website I can test this on so I know for sure its right but unfortnately I dont. sorry you have to put up with my dumbness.

Posted: Sat Feb 14, 2004 1:54 pm
by Ne0
ok, i think were getting closer:
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in c:\program files\apache group\apache\htdocs\ne0\index4.php on line 5

Code: Select all

<?php
mysql_connect(localhost,"ne0","****"); 
@mysql_select_db("db") or die( "Unable to select database"); 
$result = @mysql_query ("select * from users"); 
while ($row = mysql_fetch_object ($result)) { 
$user = $row["username"]; 
echo "$user"; 
} 
?>

Posted: Sat Feb 14, 2004 1:57 pm
by Straterra
MySQL_Fetch_Object? try mysql_fetch_array .

Posted: Sat Feb 14, 2004 2:01 pm
by tim
Straterra wrote:MySQL_Fetch_Object? try mysql_fetch_array .
I give up, i dont know what I was thinking.
mysql_fetch_array is what you would want to use (even noticing now that is what you had in your code in the beginning)

call me hank with 3 bottles of empty rum when it comes to coding today

Posted: Sat Feb 14, 2004 2:11 pm
by Ne0
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\program files\apache group\apache\htdocs\ne0\index4.php on line 5
someone up there dont want me or anyone else to get this to work...

Posted: Sat Feb 14, 2004 2:22 pm
by Straterra
Post what code you have.

Posted: Sat Feb 14, 2004 2:23 pm
by Ne0
currently:

Code: Select all

<?php 
mysql_connect(localhost,"ne0","****"); 
@mysql_select_db("db") or die( "Unable to select database"); 
$result = @mysql_query ("select * from users"); 
while ($row = mysql_fetch_array($result)) { 
$user = $row["username"]; 
echo "$user"; 
} 
?>

Posted: Sat Feb 14, 2004 2:35 pm
by d3ad1ysp0rk

Code: Select all

<?php 
mysql_connect(localhost,"ne0","****"); 
mysql_select_db("db") or die( "Unable to select database"); 
$result = mysql_query ("SELECT * FROM users"); 
while ($row = mysql_fetch_array($result)) { 
$user = $row['username']; 
echo $user; 
} 
?>

try that

Posted: Sat Feb 14, 2004 2:51 pm
by Ne0
thanks but:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\program files\apache group\apache\htdocs\ne0\index4.php on line 5

Posted: Sat Feb 14, 2004 4:08 pm
by qads

Code: Select all

<?php 
mysql_connect(localhost,"ne0","****"); 
mysql_select_db("db") or die( "Unable to select database"); 
$result = mysql_query ("SELECT * FROM `users`")or die(mysql_error()); 
while ($row = mysql_fetch_array($result)) { 
$user = $row['username']; 
echo $user;
} 
?>

try this, if there something wrong with ur query, then it will tell you.

Posted: Sat Feb 14, 2004 4:24 pm
by Ne0
i figured something out, i dont have a parse error anymore, now i have:
SELECT Error: Table 'db.users' doesn't exist in Query: SELECT * FROM users
but i do have a page that creates the database, mabey someone can explain a little better how to create a table?

ps: i also have a page that added the content, mabey that didnt work as well....

thanks

Posted: Sat Feb 14, 2004 5:30 pm
by DuFF
Use phpMyAdmin, it is invaluable when it comes to setting up databases and tables. Right now, you don't even have a table. You have to create it before you query it 8O

http://www.phpmyadmin.net/home_page/

Posted: Sat Feb 14, 2004 9:46 pm
by Ne0
accualy i do have a table, atleast my page said i do.
error when creating table:Table 'users' already exists
so, now my prblem is that it didnt insert it correctly..
error when inserting:You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'users ('','Ne0','****','moo','My Signatu
so, i contact the webhost asking what server version it is....

no, onto phpMyAdmin....
i have a problem, i am using a free host, and they create the database on request, and yes i said the, as in one.

i have downloaded phpMyAdmin, and it was so confusing, that it didnt seem to aply to what i needed, or to a free host.



so thank u everyone that has helped me, i am onther few steps closer to finishing my site.

Posted: Sat Feb 14, 2004 9:51 pm
by markl999
You INSERT query looks invalid from the small error message you pasted. Looks like you have something like "INSERT INTO users ('','Ne0','****','****','My Signature')" when it should be "INSERT INTO users VALUES ('','Ne0','****',****','My Signature')"