TheCatapult Posted March 16, 2012 Share Posted March 16, 2012 Hi friends, I'm currently working in my Update page. I got this following error. Parse error: syntax error, unexpected '<' in /srv/disk4/741839/www/catapultphpmysql.eu.pn/testwebsite/djselect.php on line 17 Here's my file code. <?$id=$_GET['id'];$username="";$password="";$database="";mysql_connect("",$username,$password);$query=" SELECT * FROM diskjockey1 WHERE jockey='$jockey'";$result=mysql_query($query);$num=mysql_numrows($result);mysql_close();$i=0;while ($i < $num) {$jockey=mysql_result($result,$i,"jockey");<form action="updated.php" method="post"> Input the current DJ: <input type="text" name="ud_web" value="<? echo $jockey; ?>"><br><input type="Submit" value="Update"></form>++$i;}?> Here's the updated.php. <?$ud_jockey=$_POST['ud_jockey'];$username="";$password="";$database="";mysql_connect("",$username,$password);$query="UPDATE diskjockey1 SET first='$ud_jockey'";mysql_query($query);echo "Record Updated";mysql_close();?> Thanks and I am hoping for helpful answers! Link to comment Share on other sites More sharing options...
niche Posted March 17, 2012 Share Posted March 17, 2012 To begin with, you need to echo these lines or take them out of php: <form action="updated.php" method="post"> Input the current DJ: <input type="text" name="ud_web" value="<? echo $jockey; ?>"><br><input type="Submit" value="Update"></form> EDIT: I don't know how the second script fits into your question. Link to comment Share on other sites More sharing options...
TheCatapult Posted March 17, 2012 Author Share Posted March 17, 2012 niche, I just follow the tutorials here. http://www.freewebmasterhelp.com/tutorials/phpmysql/7 Please help me, niche. All the best,The Catapult Link to comment Share on other sites More sharing options...
niche Posted March 17, 2012 Share Posted March 17, 2012 Part of the tutorial would have said that html has to be echoed when it's left in the php flow. You can take your html out of the php like this. <?phpphp here?>html here<?phpmore php here?> That will eliminate the parse error. Link to comment Share on other sites More sharing options...
TheCatapult Posted March 17, 2012 Author Share Posted March 17, 2012 Thanks niche! I did that and another error happened. [b]Warning[/b]: mysql_numrows(): supplied argument is not a valid MySQL result resource in [b]/srv/disk4/741839/www/catapultphpmysql.eu.pn/testwebsite/djselect.php[/b] on line [b]10[/b] When I remove the numrows, it leaves a blank page without the form.Please help! Link to comment Share on other sites More sharing options...
birbal Posted March 17, 2012 Share Posted March 17, 2012 your quuery is failing so $result is not mysql resource it is boolean false. so that mysql_num_rows() issuing a error. if($result){ //onsuccess do that}elseecho mysql_error(); mysql_error()will print the error. Link to comment Share on other sites More sharing options...
TheCatapult Posted March 17, 2012 Author Share Posted March 17, 2012 birbal, sorry if I am so whatnot here. <?$id=$_GET['id'];$username="";$password=";$database="7;mysql_connect("",$username,$password);$query=" SELECT * FROM diskjockey1 WHERE jockey='$jockey'";$result=mysql_query($query);$num=mysql_numrows($result);mysql_close();if($result){//onsuccess do that}elseecho mysql_error();$i=0;while ($i < $num) {$jockey=mysql_result($result,$i,"jockey");?><form action="updated.php" method="post"> Input the current DJ: <input type="text" name="ud_web" value="<? echo $jockey; ?>"><br><input type="Submit" value="Update"></form><?++$i;}?> That's the code. Still, it has error. Link to comment Share on other sites More sharing options...
thescientist Posted March 19, 2012 Share Posted March 19, 2012 what about these lines. no closing quote, only one single quote. $password = ";$database = "7; My question though is, why all your success code seems to be outside of the if conditional. Shouldn't you be executing the loop only if $result is valid? I would definitely add some error logging and debugging statements. Take it one step at a time and make sure the DB connection is valid, then make sure your query is successful, then execute the loop. Make sure the first step works before moving onto the next one. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.