new 2 mysql and im sure this is easy...



if i have an sql statment how to i write it to a database using a php page?

echo "$value" ; will print Hello
echo '$value' ; will print $value

if your use single quote or block quote it will ask the interpreter don't evaluate this value but put it as it is.

$db=mysql_select_db("tests",$link) or die("No DB Selected ") ;
$q='insert into table(name,id) values ($vale,$id)';

mysql_query("INSERT INTO `queries` ( `name` , `id` ) VALUES ('$q', '0')") or mysql_error();

I Tested this query and worked ..replace names with your ones
dont i need to tell it the db details like username etc?

sorry i am new to this!
First you connect to database
select db
then make your query
mysql_query("Your Query Here");

This is what you do to connect to mysql from php script

by the way which database you are using :?: :idea:
i must be doing something wrong this does not work


mysql_query("INSERT INTO phpuserlogin_users (`username`, `password`, `email`) VALUES (

i get

Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on '' (61) in /freeola/users/8/1/sr0254618/htdocs/pages/newuser.php on line 2

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /freeola/users/8/1/sr0254618/htdocs/pages/newuser.php on line 3

Warning: mysql_query() [function.mysql-query]: Access denied for user: 'root@localhost' (Using password: NO) in /freeola/users/8/1/sr0254618/htdocs/pages/newuser.php on line 8

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /freeola/users/8/1/sr0254618/htdocs/pages/newuser.php on line 8
Read errors
check your hostname (is it valid)
check your query
kinda that is the problem. your code is spot on. i was trying to connect to that db hosted by one company from a php page on another host and they have set it so that you have to access it from their ip addresses if u understand.....

thanks for you help your code is A-OK!

Thanks again!