Jump to content

Recommended Posts

my code is this

<?php

$con = mysql_connect("localhost","apnimusk","password");

if (!$con)

{

die('Could not connect: ' . mysql_error());

}

mysql_select_db("apnimusk_naat", $con);

 

// check to see if id is set

if(isset($_GET['id']) && is_numeric($_GET['id']))

{

echo 'Your have requested ID #'.$_GET['id'].'<br />';

echo '<a href="sadasdas.php">Back</a>';

}

// no id requested, display results

 

else

{

$result = mysql_query("SELECT * FROM album");

 

echo "<table border='1'>

<tr>

<th>Firstname</th>

<th>Lastname</th>

</tr>";

 

while($row = mysql_fetch_assoc($result))

{

echo "<tr>";

echo "<td>" . '<a href="?id='$row['id']'">'$row['name']'</a>' ."</td>";

echo "<td>" . $row['age'] . "</td>";

echo "<tr>";

}

echo "</table>";

 

mysql_close($con);

?>

 

it is giving error

Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /home1/apnimusk/public_html/sadasdas.php on line 30

Link to comment
https://forums.phpfreaks.com/topic/121225-solved-where-am-i-wroung/
Share on other sites

<?php

$con = mysql_connect("localhost","apnimusk","password");

if (!$con)

{

die('Could not connect: ' . mysql_error());

}

mysql_select_db("apnimusk_naat", $con);

 

// check to see if id is set

if(isset($_GET['id']) && is_numeric($_GET['id']))

{

echo 'Your have requested ID #'.$_GET['id'].'<br />';

echo '<a href="sadasdas.php">Back</a>';

}

// no id requested, display results

 

else

{

$result = mysql_query("SELECT * FROM album");

 

echo "<table border='1'>

<tr>

<th>Firstname</th>

<th>Lastname</th>

</tr>";

 

while($row = mysql_fetch_assoc($result))

{

  echo "<tr>";

  echo "<td><a href='?id=".$row['id']."'>".$row['name']."[/a]</td>";

  echo "<td>" . $row['age'] . "</td>";

  echo "<tr>";

}

echo "</table>";

 

mysql_close($con);

?>

 

 

this  is code i am using

Not closing your if statement. The one that checks if id is set.

 

What Blade meant was, use [ code ] [ / code ] tags, minus the spaces. It allows the forums to display it neater and show syntax errors.

 

Oh and if you continue to get parse errors and what not, check out this thread, it should help you a bit.

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.