zero-perfoliate
zero-perfoliate

Author Topic: MySQL Error  (Read 1272 times)

Offline R4nk3d

  • PHP Workers
  • **
  • Posts: 8
  • Karma: +0/-0
MySQL Error
« on: July 31, 2008, 08:27:43 PM »
Code: [Select]
$content = mysql_query("SELECT * FROM pages WHERE page = ".$_GET['page']);
$row = mysql_fetch_array($content); //Line 57
$format = "<form name=\"editing\" action=\"index.php?pg=edit&type=page&page=".$_GET['page']."&editing=1\" method=\"post\" >Title:<input type=\"text\" name=\"name\" value=".$row['title']."><br><textarea rows=\"50\" cols=\"70\">".$row['details']."</textarea><br><input type=\"submit\" value=\"Edit\"></form>";
echo $format;
Ok, i got my code there, but when i try to load the page it gives me a warning:
Code: [Select]
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/content/r/4/n/r4nk3d/html/new/pages/edit.php on line 57it seems legit to me. im new to using sql with this so please help.

icestormz

  • Guest
Re: MySQL Error
« Reply #1 on: August 01, 2008, 02:30:41 AM »
could be that your mysql_connect() and/or mysql_select_db() call(s) are failing somewhere.

also make sure $content exist in your databse

Offline R4nk3d

  • PHP Workers
  • **
  • Posts: 8
  • Karma: +0/-0
Re: MySQL Error
« Reply #2 on: August 01, 2008, 05:11:56 PM »
could be that your mysql_connect() and/or mysql_select_db() call(s) are failing somewhere.

also make sure $content exist in your databse
how do i test if something exist in my database?

icestormz

  • Guest
Re: MySQL Error
« Reply #3 on: August 02, 2008, 05:32:01 PM »
give this a try should give a better and more accurate result

Code: [Select]
<?php
$content 
mysql_query('$content') or die(mysql_error());
$content mysql_query("SELECT * FROM pages WHERE page = ".$_GET['page']);
$row mysql_fetch_array($content);
$format "<form name=\"editing\" action=\"index.php?pg=edit&type=page&page=".$_GET['page']."&editing=1\" method=\"post\" >Title:<input type=\"text\" name=\"name\" value=".$row['title']."><br><textarea rows=\"50\" cols=\"70\">".$row['details']."</textarea><br><input type=\"submit\" value=\"Edit\"></form>";
echo $format;
?>