Jump to content

Recommended Posts

this is the error i am getting:

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/seodev/public_html/clients/powerproperties/press_03.php on line 55

 

 

this is my code

 

<?php

mysql_connect('localhost','seodev_admin','admin1369');

mysql_select_db('powerp');

?>

 

<ul>

 

<?php

 

//select the table

if($_GET['id']){$select="select * from press where id='$_GET[id]'";}

else{$select="select * from press";}

$result = mysql_query($select);

 

 

 

//grab all the content

while($r=mysql_fetch_array($result))    ///// this is line 55

{

  //the format is $variable = $r["nameofmysqlcolumn"];

  //modify these to match your mysql table columns

 

  $headline=$r["headline"]; 

  $source=$r["source"];

  $writer=$r["writer"];

  $pik_link=$r["pik_link"];

  $article=$r["article"];

  $date=$r["date"];

  $id=$r["id"];

 

 

  echo "<li><b class='h_03'>$headline</b>, $source";

 

 

 

}

?>

 

</ul>

 

 

 

 

not sure why this is not working .... any suggestions ..

Link to comment
https://forums.phpfreaks.com/topic/52997-solved-help-with-mysql-error/
Share on other sites

The GET id needs to be quoted at the end of the following line:

 

if($_GET['id']){$select="select * from press where id='$_GET[id]'";}

 

maybe even change the line to the following:

 

if($_GET['id']){$select="select * from press where id='{$_GET['id']}'";}

 

this is the error i got

 

Error No database selected with query select * from press

 

what does not make sense is that i am running the same exact code on my other server and it works fine .... is there a setting in php which could cause this error to happen ?

 

thanks

b

thats the problem ... there is a data base ... idk .. i put a support ticket into my hosting ...

 

seodev_admin (Privileges: ALL PRIVILEGES)

 

    Connection Strings

    Perl $dbh = DBI->connect("DBI:mysql:seodev_powerp:localhost","seodev_admin","<PASSWORD HERE>");

    PHP $dbh=mysql_connect ("localhost", "seodev_admin", "<PASSWORD HERE>") or die ('I cannot connect to the database because: ' . mysql_error());

    mysql_select_db ("seodev_powerp");

my host informed me of the wrong way to call the database ....  i needed the username of my account in front of the USER and DATABASE not just the USER.

 

1/2 my fault and half theres.

 

so technically there is nothting wrong with any of my code, jsut the wrong name for the DB.

 

stupid error ....

 

thanks guys ... i still learned somthing from your help !!!!

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.