mohaakilla51 Posted July 26, 2007 Share Posted July 26, 2007 [random side note] Hello Everyone, I am MOHAAkilla516. I have been coding HTML/Javascript for about 4 years now. I finally decided to upgrade to CSS and PHP. That is why I am here [/side note] OK, so I am trying to create a method for creating resources (Tutorial, Articles, etc.) From registered memberes of my site. Here is the code I am using to try to do this (Without all the formatting and etc.): <html> <head> <?php mysql_connect("localhost","root",""); mysql_select_db("if_847191_resources"); ?> <title><?php $title = $_GET['article']; echo $title; ?> </title> </head> <body> <?php $title = $_GET['article']; //Yeah yeah, I know that was unneccessary. Is this the proper syntax for a comment in PHP? $article = mysql_query("SELECT * FROM article WHERE title==$title"); echo $article['body']; echo "that was the article"; ?> </body> </html> I am able to connect to the database without problem. The only problem I get it that I only get a blank page, with no article! The URL I have is blah.com/resources.php?article=Test Where resources is the above page. Here is a screen shot of PHPMyAdmin: OR, If you can't see that: Click Here So the table exists. THe Data Exists. What am I doing wrong? Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 26, 2007 Share Posted July 26, 2007 edited try now. try that before i rewrite it all lol <html> <head> <?php //if password exist. $db=mysql_connect("localhost","root","password"); mysql_select_db("if_847191_resources",$db); ?> <title> <?php $title = $_GET['article']; echo $title; ?> </title> </head> <body> <?php $title=$_POST['title']; $query = "SELECT * FROM article"; $result-mysql_query($query) or die("mysql_error()"); while($article=mysql_fetch_assoc($result)){ $a=$article['body']; echo "$a that was the article"; } ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
mohaakilla51 Posted July 26, 2007 Author Share Posted July 26, 2007 Nope... And why did you put quotes around the variable name? wouldn't that screw it up? I tried it with and without.. it stil didn't work Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 26, 2007 Share Posted July 26, 2007 try now please <?php $db=mysql_connect("localhost","root",""); mysql_select_db("if_847191_resources",$db); $query = "SELECT * FROM article"; $result-mysql_query($query) or die("mysql_error()"); while($article=mysql_fetch_assoc($result)){ $a=$article['body']; echo "$a that was the article"; } ?> Quote Link to comment Share on other sites More sharing options...
mohaakilla51 Posted July 26, 2007 Author Share Posted July 26, 2007 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\wamp\www\acdec\resource.php on line 28 I have no idea what that Mysql_fetch_assoc is so I do not know how to fix this... BTW, thanks for the help so far red arrow... YOU ROCK Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 26, 2007 Share Posted July 26, 2007 <?php $db=mysql_connect("localhost","root",""); mysql_select_db("if_847191_resources",$db); $query = "SELECT * FROM article"; $result=mysql_query($query) or die("mysql_error()"); while($article=mysql_fetch_assoc($result)){ $a=$article['body']; echo "$a that was the article"; } ?> Quote Link to comment Share on other sites More sharing options...
DeadEvil Posted July 26, 2007 Share Posted July 26, 2007 I think this part of code is wrong.. $title = $_GET['article']; //Yeah yeah, I know that was unneccessary. Is this the proper syntax for a comment in PHP? $article = mysql_query("SELECT * FROM article WHERE title==$title"); try to change.. $title = $_GET['article']; //Yeah yeah, I know that was unneccessary. Is this the proper syntax for a comment in PHP? $article = mysql_query("SELECT * FROM article WHERE title=$title"); $data = $mysql_fetch_array($article); # check if there's query result print_r($data); exit; Quote Link to comment Share on other sites More sharing options...
mohaakilla51 Posted July 26, 2007 Author Share Posted July 26, 2007 Thank You both SO much!!! Red Arrows Method Worked, but Thank you for posting Dead Evil... I wish Karma was enabled... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.