heroprotagonist Posted May 22, 2009 Share Posted May 22, 2009 ARG!!! What am I doing wrong? //code <?php $id=$_GET['id']; include 'config.php'; include 'opendb.php'; $result = mysql_query(" SELECT * FROM `tbl_shrinkage_data` WHERE id='$id'") or die(mysql_error()); $row = mysql_fetch_array( $result ); if ($row == empty) { //Line 61 $sql = " INSERT INTO `labdb`.`tbl_shrinkage_data`(lab_report_no) SELECT `tbl_report_data`.`lab_report_no` FROM `labdb`.`tbl_report_data` WHERE id='$id'"; } else { header("Location: shrink_entry.php"); echo "ERROR: ".mysql_error(); } ?> Thanks! Link to comment https://forums.phpfreaks.com/topic/159270-parse-error-syntax-error-unexpected-expecting-on-line-61/ Share on other sites More sharing options...
dennismonsewicz Posted May 22, 2009 Share Posted May 22, 2009 change if ($row == empty) { to this if (empty($row)) { Link to comment https://forums.phpfreaks.com/topic/159270-parse-error-syntax-error-unexpected-expecting-on-line-61/#findComment-840001 Share on other sites More sharing options...
heroprotagonist Posted May 22, 2009 Author Share Posted May 22, 2009 change if ($row == empty) { to this if (empty($row)) { ok that worked great no more error! I now have another issue... This statement is designed to query one table and check if a value is present and if not query another table and copy the value from one table to the other based on a shared auto incremented field called id. I am passing the id info from a link in the previous page. If I run the - INSERT INTO `labdb`.`tbl_shrinkage_data`(lab_report_no) SELECT `tbl_report_data`.`lab_report_no` FROM `labdb`.`tbl_report_data` WHERE id=<some real id number> with a real id number on the mysql server it works fine. If i run it by running the php page I get no errors and nothing happens in the data base. Where have I gone wrong? //Code of the first page report.php this works fine. <?php if(!isset($cmd)) $id=$_GET['id']; include 'config.php'; include 'opendb.php'; mysql_select_db($dbname) or die( "Unable to select database"); $query=("SELECT * FROM `tbl_report_data` ORDER BY `lab_report_no` ASC LIMIT 0, 30 "); $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Database Output</center></b><br><br>"; ?> <center> <table width="738" border="0" cellpadding="2" cellspacing="2" bgcolor="#D4DDFF"> <tr> <th><font face="Arial, Helvetica, sans-serif">ID</font></th> <th><font face="Arial, Helvetica, sans-serif">Name</font></th> <th><font face="Arial, Helvetica, sans-serif">Material</font></th> <th><font face="Arial, Helvetica, sans-serif">Date</font></th> <th><font face="Arial, Helvetica, sans-serif">Lab Report No</font></th> <th><font face="Arial, Helvetica, sans-serif">Lot No</font></th> <th><font face="Arial, Helvetica, sans-serif">Finish</font></th> <th><font face="Arial, Helvetica, sans-serif">Yards</font></th> </tr> <? $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $name=mysql_result($result,$i,"name"); $material=mysql_result($result,$i,"material"); $date=mysql_result($result,$i,"date"); $lab_report_no=mysql_result($result,$i,"lab_report_no"); $lot_no=mysql_result($result,$i,"lot_no"); $finish=mysql_result($result,$i,"finish"); $yards=mysql_result($result,$i,"yards"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><? echo $id; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $name; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $material; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $date; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $lab_report_no; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $lot_no; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $finish; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $yards; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo "<a href='updateview3.php?cmd=edit&id=$id'>$lab_report_no - Edit</a>";?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo "<a href='updateview_shrink4.php?cmd=edit&id=$id&lab_report_no=$lab_report_no'>$lab_report_no - Edit Shrink</a>";?></font></td> </tr> //Where I pass the data... <? $i++; } echo "</table>"; echo "</div>"; echo "<hr>"; ?> //This is the code for updateview_shrink4.php what does not do what I want it to do... <?php $id=$_GET['id']; include 'config.php'; include 'opendb.php'; $result = mysql_query(" SELECT * FROM `tbl_shrinkage_data` WHERE id='$id'") or die(mysql_error()); $row = mysql_fetch_array( $result ); if (empty($row)) { $sql = " INSERT INTO `labdb`.`tbl_shrinkage_data`(lab_report_no) SELECT `tbl_report_data`.`lab_report_no` FROM `labdb`.`tbl_report_data` WHERE id='$id'"; } else { header("Location: shrink_entry.php"); echo "ERROR: ".mysql_error(); } ?> <form action="shrink_entry.php" method="post"> <strong>ID:</strong><input type="text" name="id" value="<? echo $id; ?>"> <strong>Lab Report No:</strong><input type="text" name="lab_report_no"value="<? echo $lab_report_no; ?>"> <strong>Test1 Roll No:</strong><input type="text" name="test1_roll_no"> <hr> <input type="submit" name="submit" value="submit"> </form> Thanks! ??? Link to comment https://forums.phpfreaks.com/topic/159270-parse-error-syntax-error-unexpected-expecting-on-line-61/#findComment-840028 Share on other sites More sharing options...
dennismonsewicz Posted May 22, 2009 Share Posted May 22, 2009 Are you passing the id in the URL? for example http://someurl.com/somepage.php?id=3 Also, can you use code tags when displaying code? Link to comment https://forums.phpfreaks.com/topic/159270-parse-error-syntax-error-unexpected-expecting-on-line-61/#findComment-840043 Share on other sites More sharing options...
heroprotagonist Posted May 22, 2009 Author Share Posted May 22, 2009 Are you passing the id in the URL? for example http://someurl.com/somepage.php?id=3 Also, can you use code tags when displaying code? Yes I am passing the id value through the url.. <td><font face="Arial, Helvetica, sans-serif"><? echo "<a href='updateview_shrink4.php?cmd=edit&id=$id[/color]&lab_report_no=$lab_report_no'>$lab_report_no - Edit Shrink</a>";?></font></td> </tr> //Where I pass the data... Thanks! ??? Link to comment https://forums.phpfreaks.com/topic/159270-parse-error-syntax-error-unexpected-expecting-on-line-61/#findComment-840062 Share on other sites More sharing options...
dennismonsewicz Posted May 22, 2009 Share Posted May 22, 2009 try this <td> <font face="Arial, Helvetica, sans-serif"> <?php echo "<a href='updateview_shrink4.php?cmd=edit&id=" . $id . "&lab_report_no=$lab_report_no'>" . $lab_report_no . " - Edit Shrink</a>"; ?> </font> </td> </tr> //Where I pass the data... Link to comment https://forums.phpfreaks.com/topic/159270-parse-error-syntax-error-unexpected-expecting-on-line-61/#findComment-840118 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.