Jump to content

Recommended Posts

hi,

I am trying to alter some code to try and understand it, I have a page called amend.php, it shows me all records in my table (agent_details), i can type a record number in and then hit submit and it should go to amend1.php, this iswhere it goes wrong, I have tried to edit the coding and I am getting lost, i get an error saying "Parse error: syntax error, unexpected $end in C:\wamp\www\amend1.php on line 62"
here is the amend1.php in full.

<html>
<?PHP
session_start();
?>
<HTML>

<?php
$record = $_POST['record'];
echo "Reference Number: $record<br><BR>";

$host = "localhost";
$login_name = "root";
$password = "";

//Connecting to MYSQL
MySQL_connect("$host","$login_name","$password");

//Select the database we want to use
mysql_select_db("performance_tracker") or die("Could not find database");

$result=mysql_query(" SELECT * FROM agent_details WHERE IDNumber='$record'");
$num=mysql_num_rows($result);
$i=0;
while ($i < $num) {


// collect all details for our one reference
$description=mysql_result($result,$i,"AgentName");
$text2=mysql_result($result,$i,"TeamName");
$reference=mysql_result($result,$i,"LucentLogin");
$thumb=mysql_result($result,$i,"Date Of Birth");
$img1=mysql_result($result,$i,"Sex");
$img2=mysql_result($result,$i,"Employment");

$f='<font face=Verdana,Arial,Helvetica size=2 Color=Blue';

//next we display only the details we want to allow to be changed in a form object
// the other details that we won't allow to be changed can be echoed to the screen
//note the hidden input line 3 below. We don't need to echo it to the screen
?>

<TABLE WIDTH="100%" CELLPADDING="10" CELLSPACING="0" BORDER="2"> <TR ALIGN="center" VALIGN="top">
<TD ALIGN="center" COLSPAN="1" ROWSPAN="1" BGCOLOR="#F2F2F2">

<FORM ACTION="amend2.php" METHOD="post">
<P ALIGN="LEFT">
<INPUT TYPE="hidden" NAME="IdNumber" VALUE="<? echo "$record" ?>">
<BR>Agent Name:<BR><TEXTAREA NAME="AgentName" COLS="50" ROWS="4">
<? echo "$description"?></TEXTAREA></P><P ALIGN="LEFT">Description:<BR>
<TEXTAREA NAME="ud_text2" COLS="50" ROWS="4"><? echo "$text2"?></TEXTAREA></P><HR><B>
</B><P ALIGN="LEFT">Thumbnail:<BR> <INPUT TYPE="text" NAME="ud_thumb" VALUE="<? echo "$thumb"?>" SIZE="30" MAXLENGTH="50"></P><P ALIGN="LEFT">Image
1 :<BR> <INPUT TYPE="text" NAME="ud_img1" VALUE="<? echo "$img1"?>" SIZE="30" MAXLENGTH="50"></P><P ALIGN="LEFT">Image
2 :<BR> <INPUT TYPE="text" NAME="ud_img2" VALUE="<? echo "$img2"?>" SIZE="30" MAXLENGTH="50"></P><P ALIGN="LEFT">Image
3 :<BR> <INPUT TYPE="text" NAME="ud_img3" VALUE="<? echo "$img3"?>" SIZE="30" MAXLENGTH="50"><BR><BR>
</P><P><INPUT TYPE="Submit" VALUE="Update the Record" NAME="Submit"> </P></FORM></TD></TR></TABLE>

<?
++$i;
}
?>

can someone please tell me what I have or havnt done and how to get it show the record in a table, that I have selected on amend.php, as I believe this is what it is trying to get me todo, but i can get it to work.

thanks
Link to comment
https://forums.phpfreaks.com/topic/5958-not-sure-what-i-am-doing/
Share on other sites

First find the error . Replace

[code]$result=mysql_query(" SELECT * FROM agent_details WHERE IDNumber='$record'");[/code]

with

[code]

$sql= "SELECT * FROM agent_details WHERE IDNumber='$record' ";
echo $sql;

$result=mysql_query ($sql) or die (mysql_error()); [/code]



Another thing

[code]$num=mysql_num_rows($result);
$i=0;
while ($i < $num) {[/code]

If $i=0, then 0 will always be less than $num , correct ?
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.