Hi i was making this code so I could connect to my server and run a database:

<?php
mysql_connect("localhost","root", "samiscool");
mysql_select_db("test_db");

$sql = mysql_query("SELECT * FROM test_table");

while ($rows = mysql_fetch_assoc($sq1)) (
    var_dump ($rows)
)
?>

and this eror message came up "supplied argument is not a valid MySQL result resource"
Whats Wrong?

Recommended Answers

All 4 Replies

Might help to say what line.

looks like you may have mistyped this

mysql_fetch_assoc($sq1)

should be

mysql_fetch_assoc($sql)

caln u give me you db

echo $s="SELECT * FROM test_table";
$sql = mysql_query($s);exit;

then see what echoed in your page...and execute that query in your database...then we will get what the error..
other wise go for another option...
reply with what happened...

Hi I ran the queries in my database now when I run the php script nothing comes up!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.