0
<?
$connect = mysql_connect("localhost", "adamf", "adamf123") or 
    die ("Wrong password, jerk.");

mysql_select_db ("adamf");

$insert="INSERT INTO product (product_id, product_name, product_type, product_brand, product_year)
    VALUES (1, 'Cyber', 1, 1, 2001),
    (2, 'Motive', 8, 1, 2005),
    (3, 'Oracle', 8, 2, 2005)";
$results = mysql_query($insert)
    or die(mysql_error());

$type="INSERT INTO producttype (producttype_id, producttype_label)
    VALUES (1, 'Heads'),
    (2, 'Shafts'),
    (3, 'Helmets'),
    (4, 'Gloves'),
    (5, 'Arm Pads'),
    (6, 'Shoulder Pads'),
    (7, 'Stringing'),
    (8, 'New'),
$results=mysql_query($type)
    or die(mysql_error());

echo "Data inserted successfully!";
?>

okay, line 26 is the "echo "Data inserted successfully!"; line, so, my guess is the line above it has the error. However, I don't see what the heck it could be. I'm pretty much copying this out of the wrox book "PHP, Apache, MySQL Web Developement", just with different words and other such things, so it isn't a movie site. I've probably looked at this for 20 minutes, could anybody tell me what's wrong?

Edited by diafol: formATTING CODE

9
Contributors
10
Replies
32
Views
12 Years
Discussion Span
Last Post by get-innocuous
1
<?
$connect = mysql_connect("localhost", "adamf", "adamf123") or 
die ("Wrong password, jerk.");

mysql_select_db ("adamf");

$insert="INSERT INTO product (product_id, product_name, product_type, product_brand, product_year)
VALUES (1, 'Cyber', 1, 1, 2001),
(2, 'Motive', 8, 1, 2005),
(3, 'Oracle', 8, 2, 2005)";
$results = mysql_query($insert)
or die(mysql_error());

$type="INSERT INTO producttype (producttype_id, producttype_label)
VALUES (1, 'Heads'),
(2, 'Shafts'),
(3, 'Helmets'),
(4, 'Gloves'),
(5, 'Arm Pads'),
(6, 'Shoulder Pads'),
(7, 'Stringing'),
(8, 'New')";
$results=mysql_query($type)
or die(mysql_error());

echo "Data inserted successfully!";
?>

According to your error, in your code you forgot to put "; in the end of $type sentence. Hope it works. If this is not, insert data row by row.

Votes + Comments
1

Good answer. I solved my problem too.

I'm sure he heard you. By the way, can I borrow your necronomicon so I can resurrect the dead as well? Come on, this thread is over 5 years old

Votes + Comments
bwahahaha LMAO XD
0

I'm sure he heard you. By the way, can I borrow your necronomicon so I can resurrect the dead as well? Come on, this thread is over 5 years old

I'm just new at online foruns.

Probably he will not hear me, but oder IT curious like me will see the answer. I'm not a IT professional. Just learning a little bit.

See you.

0

In fact, it helped me now ;) this should be the meaning of an online forum, to give solutions to anyone passing by.,.
Hey, I'm also interested in the necronomicon... after it will be in my hands, the world will be ruled by IT professionals!!!! MUAHAHAHAHAHA

0

I agree with thirdeye and so does Google since this was the #1 result on page 1 when I searched for this error. New is not always the answer when tried and true is available.

0

Parse error: syntax error, unexpected T_STRING in /home/dwashington/public_html/roster.php on line 5

^^^This is the error im receiving for my php file.....what is the problem??

<!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" xml:lang="en" lang="en">   

    <?php// connect and select a database
    mysql_connect("localhost","root","hakeem42");
    mysql_select_db("active_roster");
    // Run a Query
    $result = mysql_query("SELECT * FROM roster 2011 WHERE 1");
    ?>



    <body>
    <h1> St. Louis Cardinals </h1>
    <table border="1" cellpadding="3" cellspacing ="0">
    <tr>
<th>Player</th>
<th>Team </th>
<th> Pos </th>
<th> G </th>
<th> AB </th>
<th> R </th>
<th> H </th>
<th> 2B </th>
<th> 3B </th>
<th> HR </th>
<th> RBI </th>
<th> BB </th>
<th> SO </th>
<th> SB </th>
<th> CS </th>
<th> AVG </th>
    </tr>

    <?php

    //loop though all the records

    while ($row = mysql_fetch_array($result))

    {

    echo "<tr>";

    echo "<td>" . $row['player'] . "</td>";

    echo "<td>" . $row['team'] . "<td>";

    echo "<td>" . $row['pos'] . "<td>";

    echo "<td>" . $row['g'] . "</td>";

    echo "<td>" . $row['ab'] . "</td>";

echo "<td>" . $row['r'] . "</td>"

echo "<td>" . $row['h'] . "</td>"

echo "<td>" . $row['2b'] . "</td>"

echo "<td>" . $row['3b] . "</td>"

echo "<td>" . $row['hr'] . "</td>"

echo "<td>" . $row['rbi'] . "</td>"

echo "<td>" . $row['bb'] . "</td>"

echo "<td>" . $row['so'] . "</td>"

echo "<td>" . $row['sb'] . "</td>"

echo "<td>" . $row['cs'] . "</td>"

echo "<td>" . $row['avg'] . "</td>"


    echo "</tr>";

  }

    //wipe out result data and close connection

    mysql_free_result($result);

    mysql_close();

 ?>

    </table>

    </body>

    </html>

Edited by diafol: formatting code

0

Parse error: syntax error, unexpected T_STRING in /home/dwashington/public_html/roster.php on line 5

^^^This is the error im receiving for my php file.....what is the problem??


<!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" xml:lang="en" lang="en">

<?php// connect and select a database
mysql_connect("localhost","root","hakeem42");
mysql_select_db("active_roster");
// Run a Query
$result = mysql_query("SELECT * FROM roster 2011 WHERE 1");
?>

<body>
<h1> St. Louis Cardinals </h1>
<table border="1" cellpadding="3" cellspacing ="0">
<tr>
<th>Player</th>
<th>Team </th>
<th> Pos </th>
<th> G </th>
<th> AB </th>
<th> R </th>
<th> H </th>
<th> 2B </th>
<th> 3B </th>
<th> HR </th>
<th> RBI </th>
<th> BB </th>
<th> SO </th>
<th> SB </th>
<th> CS </th>
<th> AVG </th>
</tr>

<?php

//loop though all the records

while ($row = mysql_fetch_array($result))

{

echo "<tr>";

echo "<td>" . $row . "</td>";

echo "<td>" . $row . "<td>";

echo "<td>" . $row . "<td>";

echo "<td>" . $row . "</td>";

echo "<td>" . $row . "</td>";

echo "<td>" . $row . "</td>"

echo "<td>" . $row . "</td>"

echo "<td>" . $row . "</td>"

echo "<td>" . $row . "</td>"

echo "<td>" . $row . "</td>"

echo "<td>" . $row . "</td>"

echo "<td>" . $row . "</td>"

echo "<td>" . $row . "</td>"

echo "<td>" . $row . "</td>"

echo "<td>" . $row . "</td>"

echo "<td>" . $row . "</td>"


echo "</tr>";

}

//wipe out result data and close connection

mysql_free_result($result);

mysql_close();

?>

</table>

</body>

</html>

I bet you can see what's wrong now!

echo "<td>" . $row . "</td>"

0

Hi all - I'm having a few problems with the following error message:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at index.php:1) in facebook.php on line 37

The header code for my index.php doc is here:

----------------------------------------------------------------------

<?php
require 'facebook.php';
$app_id = "#####";
$app_secret = "#####";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
?>
<!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=utf-8" />

----------------------------------------------------------------------

Lines 35-42 of facebook.php:

public function __construct($config) {
    if (!session_id()) {
      session_start();
    }
    parent::__construct($config);
  }

----------------------------------------------------------------------

Any input would be great!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.