Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8234945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:38:43+00:00 2026-06-07T18:38:43+00:00

I am running into a frustrating problem with a PHP script that’s supposed to

  • 0

I am running into a frustrating problem with a PHP script that’s supposed to allow me to edit individual rows within my MySQL database.

This is the file where all of the rows from the database are displayed; it works just like it’s supposed to.

<table cellpadding="10">
<tr>
<td>ID</td>
<td>First Name</td>
<td>Last Name</td>
<td>E-mail</td>
<td>Phone</td>
</tr>

<?php

$username="username here";
$password="password here";
$database="database name here";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM students";
$result=mysql_query($query);
mysql_close();

while ($row=mysql_fetch_array($result)){
echo ("<tr><td>$row[id]</td>");
echo ("<td>$row[first]</td>");
echo ("<td>$row[last]</td>");
echo ("<td>$row[email]</td>");
echo ("<td>$row[phone]</td>");
echo ("<td><a href=\"StudentEdit.php?id=$row[id]\">Edit</a></td></tr>");
}
echo "</table>";

?>

As you can see, each row has an “Edit” link that is supposed to allow the user to edit that individual student’s data. Here, then, is StudentEdit.php:

<?php

$username="username";
$password="password";
$database="database";

mysql_connect(localhost,$username,$password);

$student_id = $_GET[id]; 
$query = "SELECT * FROM students WHERE id = '$student_id'"; 
$result = mysql_query($query);
$row = mysql_fetch_array($result);
mysql_close();
?>

<form method="post" action="EditStudentData.php" />

<table>

<tr>
<td><input type="hidden" name="id" value="<? echo "$row[id]" ?>"></td>
</tr>

<tr>
<td>First Name:</td>
<td><input type="text" name="first" value="<? echo "$row[first]" ?>"></td>
</tr>

<tr>
<td>Last Name:</td>
<td><input type="text" name="last" value="<? echo "$row[last]" ?>"></td>
</tr>

<tr>
<td>Phone Number:</td>
<td><input type="text" name="phone" value="<? echo "$row[phone]" ?>"></td>
</tr>

<tr>
<td>E-mail:</td>
<td><input type="text" name="email" value="<?echo "$row[email]" ?>"></td>
</tr>

</table>

</form>

When I execute this, however, I get the following error message:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home4/lukaspl1/public_html/StudentEdit.php on line 12

Any ideas what’s wrong, and how to fix it?

Thank you in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T18:38:44+00:00Added an answer on June 7, 2026 at 6:38 pm

    StudentEdit.php: you forgot to call @mysql_select_db($database) or die( "Unable to select database"); before you executed the query

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am running into an issue that seems so simplistic, is frustrating. I am
I'm running into a bit of a problem with my WCF service that is
I'm running across a very frustrating problem that I'm really hoping someone can help
I'm running into a very frustrating bug. I have a java class that reads
Running into a problem where on certain servers we get an error that the
Running into a problem. I have a table defined to hold the values of
My application keeps running into Timeout Expired SqlExceptions. The thing is that this query
EDIT: I am basically running into the following documented issue . I am using
I'm running into a problem when trying to select records from my 2005 MS-SQL
I am running into a problem with bitmaps on an Android application I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.