Jump to content

Xider

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Contact Methods

  • AIM
    XiderXL

Profile Information

  • Gender
    Not Telling

Xider's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi agian, sorry I wasn\'t able to come on here. I tried, and it still doesn\'t work. Maybe I should show you what I have so far. add.php [php:1:f2c2662c81] <?php $location = \"localhost\"; $username = \"username\"; $password = \"pass\"; $database = \"db\"; $conn = mysql_connect(\"$location\",\"$username\",\"$password\"); if (!$conn) die (\"Could not connect MySQL\"); mysql_select_db($database,$conn) or die (\"Could not open database\"); mysql_query(\"CREATE TABLE reviews ( ALTER TABLE reviews ADD id int auto_increment primary key, review_name VARCHAR(20), basic_plot VARCHAR(80), review VARCHAR(100), email VARCHAR(20), poster_url VARCHAR(20), publisher VARCHAR(20), author VARCHAR(30))\"); if($submit); { $insert = \"INSERT INTO reviews (review_name,basic_plot,review,email,poster_url,publisher,author) VALUES (\'$review_name\',\'$basic_plot\',\'$review\',\'$email\',\'$poster_url\',\'$publisher\',\'$author\')\"; mysql_query($insert) or die (\"Can\'t add to table. Please report bug to Xider.\"); } ?> [/php:1:f2c2662c81] ?>[/code]
  2. Thank you very much for your help, but theres a small problem. [php:1:ceaf638428] <?php $location = \"localhost\"; $username = \"username\"; $password = \"pass\"; $database = \"dbname\"; $conn = mysql_connect(\"$location\",\"$username\",\"$password\"); if (!$conn) die (\"Could not connect MySQL\"); mysql_select_db($database,$conn) or die (\"Could not open database\"); $query = \"SELECT id, review_name FROM reviews\"; $result = mysql_query($query); $numrows = mysql_num_rows($result); print(\"We have <b>$numrows</b> reviews in our database <p>\"); while($row = mysql_fetch_array($result)){ $id = $row[\'id\']; echo \"<A href=\"reviews.php?id=$id\"><b>$row[review_name]</b></A><br>\"; } ?> [/php:1:ceaf638428] On list.php, it comes up with these errors Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/virtual/site5/fst/var/www/html/reviews/list.php on line 14 We have reviews in our database Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/virtual/site5/fst/var/www/html/reviews/list.php on line 18 And yes, I changed review_id to id Thanks agian, sorry im such a newb :oops:
  3. Ok Im making a review script for my site, and I need a little help. First, I made add.php [php]<?php $location = "localhost"; $username = "username"; $password = "pass"; $database = "db"; $conn = mysql_connect("$location","$username","$password"); if (!$conn) die ("Could not connect MySQL"); mysql_select_db($database,$conn) or die ("Could not open database"); mysql_query("CREATE TABLE reviews ( review_name VARCHAR(20), basic_plot VARCHAR(80), review VARCHAR(100), email VARCHAR(20), poster_url VARCHAR(20), publisher VARCHAR(20), author VARCHAR(30))"); if($submit); { $insert = "INSERT INTO reviews (review_name,basic_plot,review,email,poster_url,publisher,author) VALUES (\'$review_name\',\'$basic_plot\',\'$review\',\'$email\',\'$poster_url\',\'$publisher\',\'$author\')"; mysql_query($insert) or die ("Could not add data to the table"); } ?>[/PHP] On this one, im making an edit.php and delete.php, and I have to use ID\'s to make them work. How do you get this ID stuff in. Then theres list.php [PHP] <?php $location = "localhost"; $username = "username"; $password = "pass"; $database = "db"; $conn = mysql_connect("$location","$username","$password"); if (!$conn) die ("Could not connect MySQL"); mysql_select_db($database,$conn) or die ("Could not open database"); $query = "SELECT * FROM reviews"; $result = mysql_query($query); $numrows = mysql_num_rows($result); while($row = mysql_fetch_array($result)){ print("We have <b>$numrows</b> reviews in our database <p>"); } ?> <? $query = "SELECT * FROM reviews"; $result = mysql_query($query); $numrows = mysql_num_rows($result); while($row = mysql_fetch_array($result)){ echo "<b>$row[review_name]</b><br>"; } ?> [/PHP] Well since Im a newbie, I dont know how to stop this. For all the test reviews I put, after every one, it says, \"We have X many reviews in the DB\", but I only want it to show once. Also, how do you link it to the review. Thanks!
×
×
  • 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.