| | |
@ crazy problems in sending and getting data to/from database
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Aug 2008
Posts: 2
Reputation:
Solved Threads: 0
PHP Syntax (Toggle Plain Text)
... mysql_select_db(".... database name....", $con); $sql="UPDATE INTO Picks (Day, Month, Number, Competition, Sport, Country, .....
Working:
PHP Syntax (Toggle Plain Text)
... 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>";
echo $row['Team1'] . " " . $row['vs'] . " " . $row['Team2']; echo "<br>";
echo $row['Type']; echo "</h7> <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> <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> <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> <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> <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
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:
2. Are there any unescaped quotes within the values in the database as these may through such errors
For example, if you had
If you have any
php Syntax (Toggle Plain Text)
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.
•
•
Join Date: Aug 2008
Posts: 2
Reputation:
Solved Threads: 0
•
•
•
•
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:
php Syntax (Toggle Plain Text)
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 codeecho $row['Team5'] .....intoecho $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\"
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.
look at the code below where you highlighted line 83, you have you are missing a
php Syntax (Toggle Plain Text)
echo $row['Competition2'] . " " . $row['Sport2'] . " " . $row['Country2'] . " " . $row['Time2]; echo "</h8><br><h7>";
' from $row['Time2] this is also missing in the ones following this as well. ![]() |
Similar Threads
- memory management in wndows 2000 (Windows NT / 2000 / XP)
Other Threads in the PHP Forum
- Previous Thread: fwrite and fclose Error
- Next Thread: string manipulation
| Thread Tools | Search this Thread |
apache api array beginner beneath binary broadband broken button cakephp checkbox class cms code countingeverycharactersfromastring crack cron curl database date display dynamic echo email error fcc file files folder form forms freelancing function functions google href htaccess html image include incode insert integration ip javascript joomla limit link login mail match menu method mlm mod_rewrite multiple mysql oop pageing pagerank paypal pdf php problem query radio random recursion recursiveloop remote script search server sessions sms smtp soap source space sql strip_tags subversion support! survey syntax system table template tutorial undefined update upload url validator variable video virus web window.onbeforeunload=closeme; youtube





