... mysql_select_db(".... database name....", $con);
$sql="UPDATE INTO Picks (Day, Month, Number, Competition, Sport, Country, .....

Working:

... mysql_select_db(".... database name....", $con);
$sql="INSERT INTO Picks (Day, Month, Number, Competition, Sport, Country, .....

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

2. I can't make work the output of the database data, anything I try I got this message when trying to view my page:

"Parse error: syntax error, unexpected T_STRING, expecting ']' in /home/... my username..../public_html/test/view1.php on line 83" :@

Now this is a total nonsense, because like you can see below, line 83 is in an area which is totally identical with the same areas (lines) from the previous output zones (these are the output form of 5 sports-picks, everything is totally identical in the 5 areas, just the names of the "rows" are different as you can see...).

And if the code is validated in those 2 lines what in the world is with this line?
I tried to make some crazy changes, but nothing works, and anyways everything looks 1000% correct!
I have no data what could break the PHP code, any other character in the database which is not a letter are the " : ", "+ " or " - " characters.

<?php
$con = mysql_connect("localhost","...my username...","my pasword");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("...database name...., $con);

$result = mysql_query("SELECT * FROM Picks");

while($row = mysql_fetch_array($result))
  {

echo $row['Day'] . ", 
" . $row['Month'] . "
" . $row['Number']; echo "</h7></b>***</font></div><br>"; 

echo " <table align='center' border='1' bordercolor='#c0c0c0' cellpadding='0' cellspacing='0' width='528' bgcolor='#ffffff'><tr><td>
<table align='center' border='0' cellpadding='0' cellspacing='0' width='96%' bgcolor='#ffffff'>
<tr><td><div class='descr'><p align='center'><br><h8>"; 

echo $row['Competition'] . "  " . $row['Sport'] . " " . $row['Country'] . " " . $row['Time']; echo "</h8><br><h7>";
[B]echo $row['Team1'] . " " .  $row['vs'] . " " .  $row['Team2']; echo "<br>";[/B]
echo $row['Type']; echo "</h7>&nbsp;<b>"; echo $row['Pick'] . " " . $row['Spread'] . " " . $row['Odds'] . " " . $row['Units']; 
echo "</b></font><br><br>";

echo "<h8>"; 
echo $row['Competition1'] . "  " . $row['Sport1'] . " " . $row['Country1'] . " " . $row['Time1']; echo "</h8><br><h7>";
[B]echo $row['Team3'] . " " .  $row['vs1'] . " " .  $row['Team4']; echo "<br>";[/B]
echo $row['Type1']; echo "</h7>&nbsp;<b>"; echo $row['Pick1'] . " " . $row['Spread1'] . " " . $row['Odds1'] . " " . $row['Units1']; 
echo "</b></font><br><br>";

echo "<h8>"; 
echo $row['Competition2'] . "  " . $row['Sport2'] . " " . $row['Country2'] . " " . $row['Time2]; echo "</h8><br><h7>";
[B]echo $row['Team5'] . " " .  $row['vs2'] . " " .  $row['Team6']; echo "<br>";[/B]
echo $row['Type2']; echo "</h7>&nbsp;<b>"; echo $row['Pick2'] . " " . $row['Spread2'] . " " . $row['Odds2'] . " " . $row['Units2']; 
echo "</b></font><br><br>";

echo "<h8>"; 
echo $row['Competition3'] . "  " . $row['Sport3'] . " " . $row['Country3'] . " " . $row['Time3]; echo "</h8><br><h7>";
echo $row['Team7'] . " " .  $row['vs3'] . " " .  $row['Team8']; echo "<br>";
echo $row['Type3']; echo "</h7>&nbsp;<b>"; echo $row['Pick3'] . " " . $row['Spread3'] . " " . $row['Odds3'] . " " . $row['Units3']; 
echo "</b></font><br><br>";

echo "<h8>";
echo $row['Competition4'] . "  " . $row['Sport4'] . " " . $row['Country4'] . " " . $row['Time4']; echo "</h8><br><h7>";
echo $row['Team9'] . " " .  $row['vs4'] . " " .  $row['Team10']; echo "<br>";
echo $row['Type4']; echo "</h7>&nbsp;<b>"; echo $row['Pick4'] . " " . $row['Spread4'] . " " . $row['Odds4'] . " " . $row['Units4']; 
echo "</b></font><br><br>";

}
  mysql_close($con);
?>

Line 84 is in red bold, and the other 2 identical lines are in green bold.
I'm totally out of ideas how to solve these 2 problems.... :(

1. Lookup the update statement on the internet, the syntax for it is not correct, you can't simply replace INSERT with UPDATE, you need to completely re-write it, basics below:

mysql_query("UPDATE table_name SET row_name = value, rowname = value WHERE row_name = 'value'");

2. Are there any unescaped quotes within the values in the database as these may through such errors
For example, if you had 'value' in Team5 row in the database, it would make the code echo $row['Team5'] ..... into echo $row[''value'']...... which results in value being seen as code.
If you have any ' or " in the values in the db, you can escape them by changing them to \' or \"

1. Lookup the update statement on the internet, the syntax for it is not correct, you can't simply replace INSERT with UPDATE, you need to completely re-write it, basics below:

mysql_query("UPDATE table_name SET row_name = value, rowname = value WHERE row_name = 'value'");

2. Are there any unescaped quotes within the values in the database as these may through such errors
For example, if you had 'value' in Team5 row in the database, it would make the code echo $row['Team5'] ..... into echo $row[''value'']...... which results in value being seen as code.
If you have any ' or " in the values in the db, you can escape them by changing them to \' or \"

Thanks for the info on the use of "UPDATE". I'm new to PHP, I was thinking that we need only to change"INSERT".

As about question 2, that's seems more problematic... No, I don't have any quotes in the database.

look at the code below where you highlighted line 83, you have

echo $row['Competition2'] . " " . $row['Sport2'] . " " . $row['Country2'] . " " . $row['Time2]; echo "</h8><br><h7>";

you are missing a ' from $row['Time2] this is also missing in the ones following this as well.

I think you forgot to insert single qoute for variables time2 and time3 you try to execute after removing this errors.

Comments
nice thing...
This article has been dead for over six months. Start a new discussion instead.