@ crazy problems in sending and getting data to/from database

Reply

Join Date: Aug 2008
Posts: 2
Reputation: MadMaxy is an unknown quantity at this point 
Solved Threads: 0
MadMaxy MadMaxy is offline Offline
Newbie Poster

@ crazy problems in sending and getting data to/from database

 
0
  #1
Sep 21st, 2008
  1. ... mysql_select_db(".... database name....", $con);
  2. $sql="UPDATE INTO Picks (Day, Month, Number, Competition, Sport, Country, .....
  3.  

Working:

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

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

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>";
echo $row['Team1'] . " " .  $row['vs'] . " " .  $row['Team2']; echo "<br>";
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>";
echo $row['Team3'] . " " .  $row['vs1'] . " " .  $row['Team4']; echo "<br>";
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>";
echo $row['Team5'] . " " .  $row['vs2'] . " " .  $row['Team6']; echo "<br>";
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....
Last edited by cscgal; Sep 22nd, 2008 at 12:54 pm. Reason: Fixed code tags
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 524
Reputation: Will Gresham is on a distinguished road 
Solved Threads: 86
Sponsor
Will Gresham's Avatar
Will Gresham Will Gresham is offline Offline
Posting Pro

Re: @ crazy problems in sending and getting data to/from database

 
0
  #2
Sep 21st, 2008
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:
  1. 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 \"
Last edited by Will Gresham; Sep 21st, 2008 at 8:03 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 2
Reputation: MadMaxy is an unknown quantity at this point 
Solved Threads: 0
MadMaxy MadMaxy is offline Offline
Newbie Poster

Re: @ crazy problems in sending and getting data to/from database

 
0
  #3
Sep 21st, 2008
Originally Posted by xan View Post
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:
  1. 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.
Last edited by MadMaxy; Sep 21st, 2008 at 8:11 pm.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 524
Reputation: Will Gresham is on a distinguished road 
Solved Threads: 86
Sponsor
Will Gresham's Avatar
Will Gresham Will Gresham is offline Offline
Posting Pro

Re: @ crazy problems in sending and getting data to/from database

 
0
  #4
Sep 21st, 2008
look at the code below where you highlighted line 83, you have
  1. echo $row['Competition2'] . " " . $row['Sport2'] . " " . $row['Country2'] . " " . $row['Time2]; echo "</h8><br><h7>";
  2.  
you are missing a ' from $row['Time2] this is also missing in the ones following this as well.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 31
Reputation: srilakshmitr7 is an unknown quantity at this point 
Solved Threads: 2
srilakshmitr7's Avatar
srilakshmitr7 srilakshmitr7 is offline Offline
Light Poster

Re: @ crazy problems in sending and getting data to/from database

 
1
  #5
Sep 22nd, 2008
I think you forgot to insert single qoute for variables time2 and time3 you try to execute after removing this errors.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC