Closed Thread Icon

Topic awaiting preservation: mysql_fetch_array() problem? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12534" title="Pages that link to Topic awaiting preservation: mysql_fetch_array() problem? (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: mysql_fetch_array() problem? <span class="small">(Page 1 of 1)</span>\

 
Gee
Bipolar (III) Inmate

From: London, UK
Insane since: Nov 2002

posted posted 11-28-2002 03:06

Please can you help, i connect to my database, but then I cannot get the data from my table. (I am trying to send it to the browser)

code:
mysql_select_db("projectg");
$query = "SELECT modCode, modTitle ";
$query = "FROM lecfiles ";
$query = "ORDER BY modTitle ASC";

$result = mysql_query($query);

if (!$result) {
echo "...............Couldn't get file list";
}

while($row = mysql_fetch_array($result))
{
php echo "{$row['modCode']}";
php echo "{$row['modTitle']}";
}


I am well and truly baffled.

I get the following error in my browser...

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\...\...\...

Any Ideas?

Gee



Gee
Bipolar (III) Inmate

From: London, UK
Insane since: Nov 2002

posted posted 11-28-2002 03:28

Sorry, I fixed it.

I had been debugging this script for 2 hours...
And you know what it was, 2 little dots . .

code:
$query = "SELECT modCode, modTitle ";
$query .= "FROM lecfiles ";
$query .= "ORDER BY modTitle ASC";



I tried to delete the post but it wouldnt let me.

Sorry once again.

Gee

Perfect Thunder
Paranoid (IV) Inmate

From: Milwaukee
Insane since: Oct 2001

posted posted 11-29-2002 20:57

Unless you're dynamically building a query based on other conditions, there's no real reason not to just "SELECT field1, field2 FROM table WHERE stuff=things". And even if the query is dependent on conditions, you can "SELECT $value, $value FROM $table WHERE $value = $value" -- as long as your query is contained in double quotes, variables will be expanded.

« BackwardsOnwards »

Show Forum Drop Down Menu