• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

a little PHP/mySQL help please

$db = mysql_connect("localhost","root");
mysql_query("CREATE DATABASE mydb",$db);
mysql_select_db("mydb", $db);
mysql_query("CREATE TABLE testtable (col1 varchar,col2 varchar)",$db);
mysql_query("INSERT INTO testtable VALUES('Zach','sucks')",$db);
mysql_query("INSERT INTO testtable VALUES('Mike','sucks2')",$db);
$result = mysql_query("SELECT * FROM testtable",$db);
printf("col1: %s
", mysql_result($result,0,"col1"));




I'm getting a "mysql_result(): supplied argument is not a valid MySQL result resource" error...whats the problem here? I basically copied it straight out of an example which worked...but now mine doesnt...
 
Does your root mysql account have no password?

$db = mysql_connect("localhost","root");

$db = mysql_connect("localhost","root", "rootpassword");

Rob
 
Try this...

<?
mysql_connect("localhost","root","password") or die("Could not connect to MySQL Database.");
?>

Just make sure, step by step, that it is working. Then you can figure out what isn't working.

Rob
 
Originally posted by: Entity
Try this...

<?
mysql_connect("localhost","root","password") or die("Could not connect to MySQL Database.");
?>

Just make sure, step by step, that it is working. Then you can figure out what isn't working.

Rob

tried it, first time it hits is on the secondline -> or die("Could not connect to MySQL Database.");

so connect is working right....but why does it die when i send a query?
 
Back
Top