Jump to content

simcoweb

Members
  • Posts

    1,104
  • Joined

  • Last visited

Everything posted by simcoweb

  1. simcoweb

    while

    Have you written the code for the db query yet that pulls the row based upon the id? If so, please post it.
  2. Ok, this is PHP/MySQL 101: FIRST: You must have a MySQL database. Do you? If not, you need to create one. Your hosting provider either a) provides you with some method of creating one, or b) creates one for you, or c) provides you with an address to one SECOND: That bit of code in your script has to be modified to point to the actual database you are trying to access. [quote]//////DATABASE CONFIG, AND CONNECTION $db[host] = 'localhost';          //DATABASE HOST "Default is localhost" $db[user] = 'username';    //DATABASE USERNAME $db[pass] = 'password';        //DATABASE PASSWORD $db[name] = 'admin_dbname';  //DATABASE NAME $connect = mysql_connect($db[host],$db[user], $db[pass]); mysql_select_db("$db[name]") or die ("Could not connect to database");[/quote] Where it says $db[host] = 'localhost'  as an example, you need to make sure that 'localhost' is the actual location of your database. It could be 'mysql.atmyhostproviders.com' or whatever. But, whatever it is, you need to enter it there by replacing the word 'localhost'. Same with those other variables. I doubt seriously if your database's username is 'username'. Plug in the actual username there. Same goes for the password. THIRD: EVERY database has a name. Plug that in to the $db[name] = 'admin_dbname' spot. Then you should be able to connect.
  3. replace those tags for each of those to the proper name/username/password/host
  4. Syntax errors should already display automatically. If it's a MySQL error then you need to use the 'or die(mysql_error()); extension on your queries.
  5. That %20 is a replacement for an empty space. You can't have empty spaces in a URL. It has to be populated with a dash or underscore or some other connecting character.
  6. Yeah, it is strange. But, did it fix the problem?
  7. This took a little research but it appears that your problem is with the closing EOD; tag. It needs to occupy the first column of the line it's on. In other words, don't indent it. Push it all the way left. Here's the reference on this from PHP.net: http://us2.php.net/types.string
  8. 1. $query="DELETE FROM cart WHERE bookid='$bookid'";  Capitalize your query commands. Easier to read. 2. In between <?php ?> tags you shouldn't be using double quotes " for everything. For example, the $_GET statements typically are $_GET['bookid'];  You can use double quotes inside of single quotes. http://dev.mysql.com/doc/refman/4.1/en/string-syntax.html 3. You should paste your code into the posts using the # code view so we can view it in the proper color scheme for PHP/HTML :)
  9. Create the folder like craygo pointed out: /home/user/public_html/misc/images/thumbs Your path may be different so plug in the necessary replacements. Then, set the folder permissions to 777. BUT, be SURE to put an 'index.htm' file in that folder . This prevents snoopers from simply typing in your images/thumbs url and displaying all your pics. The index.htm file will show up by default. It can be as simple as one line of text saying 'You shouldn't be here'.
  10. Please post your code you have now for summoning and displaying your products :)
  11. This is the code for displaying your results. Where's the code for uploading the picture?
  12. I'm assuming the info is in a MySQL database? If so, you'd use a query then you would display the summoned data in an HTML formatted way.
  13. Well, if it's any inspiration to you... I didn't know up from scoot about 4 months ago. I practically lived here and read post after post learning all I could. Then I wrote 3 completely different styled scripts on my own with the help of these people that included everything from file uploading to IP banning. One was an entire website in PHP. It'll all make sense once you get the terminology down and the basic concepts of the core functions and database integration. There's a load of great great sites with tutorials with each explaining it in their own way. I read through dozens of those to find the ones that explained it the way I could understand it. So, check those out and you'll learn faster.
  14. The $_GET statement 'snags' the age from the url (ex: www.yoursite.com/view.php?age=7) and populates the variable name you've assigned to it which is $age. So... $age = $_GET['age'];  snags the number 7 from the url and assigns that number as the value of $age.  Now, you need to use that variable in your mysql query like this: $sql = "SELECT age, division, team FROM MyTable WHERE age='$age'"; Note the $age variable is in the WHERE clause. So, say you had a link on your page for each age like 7, 6 , 10, etc. then the query would simply snag the age from the url and display all people/members/whatevertheyare that have that age. The 'WHERE' clause filters out all the other results since it's looking for everyone (in this case) that is the age of 7. Make sense?
  15. Do you have a WHERE age='$age'  clause in your query?
  16. Yeah, that's because the variable name used for the query is not $result. In your code it's $query. $result = mysql_query($query) or die(mysql_error()); But your SQL statement uses $sql as your variable name: $sql = "SELECT age, division, team FROM MyTable"; SO! Your $result variable should be this: $result = mysql_query($sql) or die(mysql_error()); If you read it as stated what it's saying is 'set this variable name '$result' to equal the mysql_query generated in my $sql SELECT statment' Make sense? So, change that statement to: $result = mysql_query($sql) or die(mysql_error()); Otherwise, as it sits right now, there's no such query as $result. That's why it says the query is empty.
  17. Here's what you need: http://uk2.php.net/manual/en/function.gettype.php
  18. It's not easier to show a pic by it being 'in a database'. Basically what you store 'in the database' is just the image name or the path and the name. There's loads of good tutorials and plenty of code snippets for image/file uploading. Once you understand what happens during the upload then it becomes much easier. The file is uploaded to a temporary directory initially The file is given a temporary name initially The file (temp file) should then be 'moved' to its permanent location The original file name is stored in the database field The file is called to your profile page by using the standard <img src= > tag <img src="http://www.yoursite.com/imagefolder/$image_variable_or_similar" width="400" height="300"> Or, if in a while loop example: while ($row = mysql_fetch_array($mysqlquery){ echo " <img src='http://www.yoursite.com/imagefolder/" . $row['photo'] . "' width='400' height='300'>"; }
  19. Your host most likely doesn't support your ability to make directories and set permissions. I ran into this before myself.
  20. If you set up a column in your MySQL database to be 'id' then all you need to do is set that field's properties to AUTO-INCREMENT and it will automatically add 1 each time a new entry is inserted into that table. You can pull that id # in any display as well.
  21. craygo's right on that. No sense running multiple queries for the same thing. Just for fun, let's change this: [quote]while ($row = mysql_fetch_array($sql)) {[/quote] to this and try it: [quote]while ($row = mysql_fetch_array($result)) {[/quote]
  22. Part of the problem is you have no 'action' tag in your form. Without implementing an 'action' it won't do anything.
  23. Where is this variable being set? WHERE eventid='$id'"; I'm assuming from a $_GET statement but none is present. The query needs to know that 'id' before it can produce results.
  24. Simple, you'd provide them with a link that places the age in it. Like this: http://www.mysite.com/view.php?age=7  (or similar to this example) When they click on the link it summons a script (in this case I named it view.php) and the script uses a $_GET statement to capture the age. Like this: $age = $_GET['age']; Then your mysql statement would be something like: $sql = "SELECT * FROM nameoftable WHERE age='$age'"; Then run it through a while loop: echo "<table width='500' border='0'><tr>         <th>Age></th><th>Division</th><th>Team</th></tr>"; while ($row = mysql_fetch_array($sql) { echo "<tr><td>" . $row['age'] . "</td><td>" . $row['division'] . "</td><td>" . $row['team'] . "</td></tr>"; } echo "</table>\n";
  25. Well, if your database is truly named MyDatabaseName then you're golden. But, I seriously doubt that is the case. There's 4 things you have to have in order to create a database connection. Well, five if you count the fact you have to have a database to begin with. 1. database host - typically this is 'localhost' but may differ depending on hosting company 2. database username - every database have to have a user assigned to it that has specific permissions to operate it 3. database password - self explanatory 4. [b]database name[/b] - every database has a name. You need to find out what this is So, typical connect code is: mysql_connect('databasehost', 'databaseuser', 'databasepassword') or die(mysql_error()); mysql_db_select('databasename') or die(mysql_error()); Plug in the actual information for each of those items and voila!
×
×
  • 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.