Author Topic: Problem with php?  (Read 9062 times)

0 Members and 1 Guest are viewing this topic.

Offline Jaap12

  • Full Member
  • ***
  • Posts: 108
    • View Profile
Problem with php?
« on: August 27, 2002, 03:09:24 PM »
Hi i have made this code for a modification :
Code: [Select]

<?
$dbase_connect = mysql_connect("localhost", "user", "pass");
mysql_select_db($dbnamehere, $dbase_connect); // ;
$sql = "SELECT * FROM 4images_images WHERE image_winkel BETWEEN 10 AND 40";
$resultaat = mysql_query($sql);

if ($result)
{

while ($image_winkel = mysql_fetch_object ($resultaat)) {
echo "<b>$image_winkel->winkel</b>\n";
}
}
else
{
echo "query mislukt".mysql_error();
}
?>



but i get this error:

query misluktNo Database Selected

but all the details are right
did i have seen something wrong?

Greetz,

Bas

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Problem with php?
« Reply #1 on: August 27, 2002, 03:50:20 PM »
Code: [Select]
if ($result)
{

must be
Code: [Select]
if ($resultaat)
{

Greets Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline Jaap12

  • Full Member
  • ***
  • Posts: 108
    • View Profile
Problem with php?
« Reply #2 on: August 27, 2002, 04:04:21 PM »
makes no different same error :(

i have as table:

Code: [Select]
SELECT * FROM 4images_images WHERE image_test BETWEEN 10 AND 40

don't must be something like this?

Code: [Select]
SELECT * FROM i.4images_images WHERE i.image_test BETWEEN 10 AND 40

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Problem with php?
« Reply #3 on: August 27, 2002, 04:05:55 PM »
Are you sure that $dbnamehere is filled with the right database name?

Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline Jaap12

  • Full Member
  • ***
  • Posts: 108
    • View Profile
Problem with php?
« Reply #4 on: August 27, 2002, 04:36:18 PM »
yep , i use the same details as 4images photo gallery

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Problem with php?
« Reply #5 on: August 27, 2002, 04:40:22 PM »
Can you post the whole script.

Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline Jaap12

  • Full Member
  • ***
  • Posts: 108
    • View Profile
this is
« Reply #6 on: August 27, 2002, 04:53:49 PM »
This is the hole script.

This is only a command to read the data out the database and select the different prices. And let them display on a page. But it doesn't work.

I think this is the right solution. But i don't know the database structure from your application.

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Problem with php?
« Reply #7 on: August 27, 2002, 04:55:42 PM »
You don't set $dbnamehere.

Use
Code: [Select]
$dbnamehere = "Database_Name";
or
Code: [Select]
mysql_select_db("Database_Name", $dbase_connect);

Greets Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline Jaap12

  • Full Member
  • ***
  • Posts: 108
    • View Profile
Problem with php?
« Reply #8 on: August 27, 2002, 05:11:04 PM »
sorry ,

but that's not the problem, i had set that to display the functions.
I know there must be my database name.

This was only for a example.

How do you use the "between"function?
Do you have a other way to show the data?

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Problem with php?
« Reply #9 on: August 27, 2002, 05:35:45 PM »
You have posted this error message:
Code: [Select]
No Database Selected
This means that have not selected a database correctly.

Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Problem with php?
« Reply #10 on: August 27, 2002, 06:13:24 PM »
mysql_select_db("YOURDBHERE", $dbase_connect);

is correct in your example for database connect, like Jan posted it allready
cheers
Nicky
Your first three "must do" before you ask a question ! (© by V@no)
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

nicky.net 4 4images
Signature stolen from mawenzi