slj90 Posted December 11, 2009 Share Posted December 11, 2009 Hi, I am trying to get the ID from the url... http://localhost/customerChangeDelete.php?id=1 The code I have is.. $CustomerID=$_GET['id']; Is this correct? ..I get the error: Parse error: syntax error, unexpected T_VARIABLE Thanks Quote Link to comment https://forums.phpfreaks.com/topic/184736-getting-id-from-the-url/ Share on other sites More sharing options...
rajivgonsalves Posted December 11, 2009 Share Posted December 11, 2009 there is probably a missing semicolon on the previous line post some more of your code, the code looks okay Quote Link to comment https://forums.phpfreaks.com/topic/184736-getting-id-from-the-url/#findComment-975229 Share on other sites More sharing options...
slj90 Posted December 11, 2009 Author Share Posted December 11, 2009 The error tells me that it's line 12 (which is the line in my original post) Here is the full code: <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php include “connection.php” //get id of record $CustomerID=$_GET['id']; // create query $query = "SELECT * FROM Customer WHERE CustomerID = '$CustomerID'"; // execute query - put the results in $result (an array) $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); //Check to see you have got at least 1 record if (mysql_num_rows($result) > 0) { $row = mysql_fetch_array($result); //print out record details on a form ?> <form name="form1" id="form1" method="GET" action= "customerChangeDeleteAction.php"> <table width="100%" border="0"> <tr> <td width="25%">Customer ID </td> <td width="75%"><input type="hidden" name="txtID" value="<?php echo $row["CustomerID"]; ?>" /><?php echo $row["CustomerID"]; ?><font size="2"> (Field hidden as cannot change key field)</font></td> </tr> <tr> <td>First Name</td> <td><input type="text" name="txtFirst" value="<?php echo $row["Firstnames"]; ?>"/></td> </tr> <tr> <td>Surname</td> <td><input type="text" name="txtSurname" value="<?php echo $row["Surname"]; ?>"/></td> </tr> <tr> <td>User Name</td> <td><input type="text" name="txtUser" value="<?php echo $row["Username"]; ?>"/></td> </tr> <tr> <td>Email</td> <td><input type="text" name="txtEmail" value="<?php echo $row["Email"]; ?>"/></td> </tr> <tr> <td>Password</td> <td><input type="text" name="txtPassword" value="<?php echo $row["Password"]; ?>"/></td> </tr> <tr><td><input name="Amend" type="Submit" value="Amend" /></td><td><input name="Delete" type="Submit" value="Delete" /></td></tr> </table> </form> <?php //Otherwise no rows found } // end if else echo "No rows found"; // Close the DBMS connection mysql_close($connection); ?> </body> </html> Thanks alot! Quote Link to comment https://forums.phpfreaks.com/topic/184736-getting-id-from-the-url/#findComment-975230 Share on other sites More sharing options...
oni-kun Posted December 11, 2009 Share Posted December 11, 2009 Previous poster was right: <?php include “connection.php” Should be: <?php include "connection.php"; Quote Link to comment https://forums.phpfreaks.com/topic/184736-getting-id-from-the-url/#findComment-975235 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.