Jump to content

mysql_fetch_array error


morrisbol2

Recommended Posts

Notice: Undefined index: marriageid in C:\wamp\view.php on line 5

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\view.php on line 7

 

require("db.php");
$id =$_REQUEST['marriageid']; <--error line 5
$result = mysql_query("SELECT * FROM parish WHERE marriageid  = '$id'");
$test = mysql_fetch_array($result); <--error line 7

 

i dont know why have an error pls help me guys

Link to comment
Share on other sites

just remember when echoing in the "while" to display items from you database it will be something like this "$row[id]" if you want it like this "$id" you need to add in this right below the "while(){"

 

list($id, $someotherstuff) = $row;

inside the brackets must be listed exactly the same order how your database is laid out.

Link to comment
Share on other sites

inside the brackets must be listed exactly the same order how your database is laid out.

 

What do you mean by that?

 

ill show an example of one of my database...

Table: blogs

rows: id, date, blog, user

 

so for the "list" it would be something like this

<?php
$r_blog = mysql_query('SELECT * FROM blogs DECS')
or die('Blog Query Failed: '.mysql_error());

while($row = mysql_fetch_array($r_blog){
    list($id, $date, $blog, $user) = $row;

echo $date."<br>".$blog."<br>- ".$user;
}
?>

Link to comment
Share on other sites

inside the brackets must be listed exactly the same order how your database is laid out.

 

What do you mean by that?

 

Only if you use "SELECT *", but then you should always specify the columns you want and not use '*'. In that case the list() should reflect the order specified in the SELECT clause.

Link to comment
Share on other sites

im sorry morrisbol2 i threw this topic off topic :/

 

Only if you use "SELECT *", but then you should always specify the columns you want and not use '*'. In that case the list() should reflect the order specified in the SELECT clause.

i always use "*" cuz most of the time I use all colums in my database

Link to comment
Share on other sites

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.