PDA

View Full Version : if i post my code here do you think you could figure out whats wrong?


Jbradshaw91
05-05-2007, 11:23 PM
<?php
require_once("Connections/connection.php"); // database connection

/////////////////////////
$query =sprintf("SELECT * FROM table1");
$result =@mysql_query($query);
$row =mysql_fetch_array($result);


echo $row["field2"];


?>



thats what i got what is wrong?

davidj
05-05-2007, 11:25 PM
post the contents of the connection.php

Jbradshaw91
05-05-2007, 11:31 PM
<?php
// This is a database connection script //
$database = "jbwd";
$username = "Justin";
$password = "yellow91";
//////////////////////////////////////////

$link = @mysql_connect("localhost", $username, $password);
$db = mysql_select_db ($database, &link);

?>

davidj
05-05-2007, 11:36 PM
check your $link variable....


$db = mysql_select_db ($database, &link);


its prefixed with an ampersand. Should be a dollar

Jbradshaw91
05-05-2007, 11:39 PM
ok thanks mate ill give it a try

Jbradshaw91
05-05-2007, 11:49 PM
ok did that and this is what happens now

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in G:\Documents and Settings\Justin\Local Root\Test\Connections\connection.php on line 9

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in G:\Documents and Settings\Justin\Local Root\Test\jbwd.php on line 7

davidj
05-05-2007, 11:52 PM
thats ok

its just a warning which can be supressed by adding an @


$db = @mysql_select_db ($database, $link); //<< where you have this in your connection.php note the @ position

Torin
09-04-2007, 06:35 AM
Isn't this post in the wrong forum? o.O