PDA

View Full Version : trouble with php coding


larryl
04-08-2007, 12:49 AM
I have follow the video tutorial up to part seven with no problems. However when I go to preview the code at the end of the lesson, as instructed, I get this error,
Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\Web Root\Test\Connections\connection.php on line 9
Besides the fact that I did not set an alias to the My Documents folder (opting to use the WWW folder in Wamp5) I believe I followed your instructions to the letter, however I still am receiving this syntax error stating that there is something wrong with my connection code.

Here is the connection code I have:

<?php
//database connection script////////////
$database = "dwc";
$username = "lj";
$password = "12345678"
////////////////////////////////////////


$link = @mysql_connect('localhost', $username, $password);
$db = mysql_select db($database, $link);

?>

And here is my dwc.php test file

<?php
require_once("connections/connection.php"); ///database connection

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

echo $row["field2"];

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
</body>
</html>

Any help would be greatly appreciated.

Larry Levins

davidj
04-08-2007, 10:20 AM
you havnt terminated the line which sets your password variable

$password = "12345678"; //<< semicolon missing

larryl
04-09-2007, 02:06 AM
Now I am getting this.

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\Web Root\Test\dwc.php on line 7

<?php
require_once("connections/connection.php"); ///database connection

/////////////////////////////////////////////////////////
$query = sprintf("SELECT * FROM table 1");
$result = @mysql_query($query);
LINE 7 $row = mysql_fetch_array($result);
/////////////////////////////////////////////////////////

echo $row["field2"];

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
</body>
</html>

By the way, thank you for the help. I usually can figure this type of stuff out on my own, but boy am I stumped.

seco
04-09-2007, 08:22 AM
dont use wamp server it goes bad !!
user other

good luck

davidj
04-09-2007, 09:56 AM
dont use wamp server it goes bad

how does it do that? past its sell by date? like a tomato

do you have any intelligent argument to back this up because i, and the members would like to hear your professional opinion with examples of bugs and "Badness" as you put it. If you have issues with WAMP5 let us know and if you convince me that its BAD! then i will withdraw my interest in it. The stage is yours.........

[[tumbleweed]]
http://www.peoplesrepublicofdis.co.uk/albums/album16/tumbleweed.sized.jpeg

anyhoo...

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\Web Root\Test\dwc.php on line 7


this is warning which is displaying correctly. Just supress it by using an @

example...

$row = @mysql_fetch_array($result);

NOTE: it had nothing to do with wamp5 being bad!