PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 2nd, 2007, 03:35 PM
gavy gavy is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2007
Posts: 31 gavy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 29 m 42 sec
Reputation Power: 11
I think i will die

i am doing php as hearby all have known, i am stuck at the problem, the value of cat_id is not passing as it is being defined in the function.

here it is below:

function get_mobiles()
{
$query = "SELECT * FROM items WHERE cat_id='$cat_id';
echo "$query";
$result = mysql_query($query) or die('Invalid query: ' . mysql_error());
if (!$result)
return false;
$numberofcategories = mysql_num_rows($result);
if ($numberofcategories==0)
return false;
$result = _result_to_array($result);
return $result;
}

i am getting this big prblem error:

SELECT * FROM items WHERE cat_id=''

well on my address bar, the value of the category is passed which next chooses from the items table which is connected to categories, the id is passed on the address bar as cart.php?id=1

it should show the items who have the cat_id of 1 but when i hardcode the value of 1 in the above query which is generating the error, the function properly works, plz help me

and sorry for all the php i said in my previous posts.

Last edited by gavy : June 2nd, 2007 at 03:36 PM. Reason: ok

Reply With Quote
  #2  
Old June 2nd, 2007, 09:52 PM
TerraTuner TerraTuner is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 11 TerraTuner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 33 m 35 sec
Reputation Power: 0
Is this function a part of a class?

Quote:
Originally Posted by gavy
i am doing php as hearby all have known, i am stuck at the problem, the value of cat_id is not passing as it is being defined in the function.

here it is below:

function get_mobiles()
{
$query = "SELECT * FROM items WHERE cat_id='$cat_id';
echo "$query";
$result = mysql_query($query) or die('Invalid query: ' . mysql_error());
if (!$result)
return false;
$numberofcategories = mysql_num_rows($result);
if ($numberofcategories==0)
return false;
$result = _result_to_array($result);
return $result;
}

i am getting this big prblem error:

SELECT * FROM items WHERE cat_id=''

well on my address bar, the value of the category is passed which next chooses from the items table which is connected to categories, the id is passed on the address bar as cart.php?id=1

it should show the items who have the cat_id of 1 but when i hardcode the value of 1 in the above query which is generating the error, the function properly works, plz help me

and sorry for all the php i said in my previous posts.


I'm have not tested the function, but I found one obviously mistake; A quotation mark was missing. Hope this helps..

PHP Code:
<?php
function get_mobiles()
{
$query "SELECT * FROM items WHERE cat_id='$cat_id'"// A quotation mark was missing here (")
echo "$query";
$result mysql_query($query) or die('Invalid query: ' mysql_error());
if (!
$result)
return 
false;
$numberofcategories mysql_num_rows($result);
if (
$numberofcategories==0)
return 
false;
$result _result_to_array($result);
return 
$result;
}
?>

Reply With Quote
  #3  
Old June 2nd, 2007, 11:50 PM
gavy gavy is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2007
Posts: 31 gavy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 29 m 42 sec
Reputation Power: 11
leave the whole above bunch of code, i restarted the application to build upon and cam eto same error but through different procedure here is what i am calling:

print ("<tr><td><a href=morder.php");
print ("?p_id=");
print($row['id']);
print(">");
print($row['p_name']);
print("</a></td>");

it is calling the id from database, the link shows properly the values of the id as 1,2 etc, now when i clik the link the value is not passed as: NULL


this is te error


SELECT * FROM catalog WHERE id=
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\wamp\www\PPP_Cart\morder.php on line 63

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\wamp\www\PPP_Cart\morder.php on line 64

this is the code:

$query2="SELECT * FROM catalog WHERE id=$p_id";
echo "$query2";

plz help me thanks asap

Reply With Quote
  #4  
Old June 3rd, 2007, 02:21 AM
Mittineague's Avatar
Mittineague Mittineague is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jul 2005
Location: West Springfield, Massachusetts
Posts: 552 Mittineague User rank is Private First Class (20 - 50 Reputation Level)Mittineague User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 1 m 33 sec
Reputation Power: 13
resource

The "result resource" error means that there were no results for mysql_result to get a result from. This could be from any number of failures (cnx, query, syntax, mis-naming, etc).
If you temporarily pepper your code with echo and die messages you should be able to pinpoint the culprit.
Does echo "$query2"; look OK?

Reply With Quote
  #5  
Old June 3rd, 2007, 03:00 AM
gavy gavy is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2007
Posts: 31 gavy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 29 m 42 sec
Reputation Power: 11
Quote:
Originally Posted by Mittineague
The "result resource" error means that there were no results for mysql_result to get a result from. This could be from any number of failures (cnx, query, syntax, mis-naming, etc).
If you temporarily pepper your code with echo and die messages you should be able to pinpoint the culprit.
Does echo "$query2"; look OK?


i tried the echo $query and die but there seems to an error: in the

SELECT * FROM catalog WHERE id=''

a value must be pased from previous page but it is not being passed and that's why it is showng mysql_results error but in case i want to know why the value is not being passed from the link as:

print ("<tr><td><a href=morder.php");
print ("?p_id=");
print($row['id']);
print(">");
print($row['p_name']);
print("</a></td>");

Reply With Quote
  #6  
Old June 3rd, 2007, 07:48 AM
TerraTuner TerraTuner is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 11 TerraTuner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 33 m 35 sec
Reputation Power: 0
Quote:
Originally Posted by gavy
i tried the echo $query and die but there seems to an error: in the

SELECT * FROM catalog WHERE id=''

a value must be pased from previous page but it is not being passed and that's why it is showng mysql_results error but in case i want to know why the value is not being passed from the link as:

print ("<tr><td><a href=morder.php");
print ("?p_id=");
print($row['id']);
print(">");
print($row['p_name']);
print("</a></td>");


Hi Sir!

Maybe i'm just slow, but I'm having a hard time trying to figure out exactly what the problem is. If you can post the database tables to me, pluss your entire class/function and other scripts I probably will be able to help you.

At least I'll give it a shot

Reply With Quote
  #7  
Old June 3rd, 2007, 12:14 PM
Mittineague's Avatar
Mittineague Mittineague is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jul 2005
Location: West Springfield, Massachusetts
Posts: 552 Mittineague User rank is Private First Class (20 - 50 Reputation Level)Mittineague User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 1 m 33 sec
Reputation Power: 13
bugs

Just to make sure I'm clear on this.
echo "$query2";
shows
SELECT * FROM catalog WHERE id=''
which means the $p_id variable is empty.
The value for $p_id comes from the links p_id GET variable which has the value of $row['id']
When you look at the link in source view, it's not empty.
How are you assigning the value of the GET variable to the $p_id variable?

Reply With Quote
  #8  
Old June 3rd, 2007, 12:45 PM
TerraTuner TerraTuner is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 11 TerraTuner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 33 m 35 sec
Reputation Power: 0
Quote:
Originally Posted by Mittineague
Just to make sure I'm clear on this.
echo "$query2";
shows
SELECT * FROM catalog WHERE id=''
which means the $p_id variable is empty.
The value for $p_id comes from the links p_id GET variable which has the value of $row['id']
When you look at the link in source view, it's not empty.
How are you assigning the value of the GET variable to the $p_id variable?


Ok, now I think I know what you're asking:
"How do I assign the $_GET?p_id=variable to the "SELECT * FROM catalog WHERE id='' ?"

If that is the question, then this i the answer:
PHP Code:
 $p_id $_GET['p_id']; // Store the $_GET['variable_value'] in the $p_id varable

$query2="SELECT * FROM catalog WHERE id=$p_id"

echo 
"$query2"


If I'm lost on what your question is, then please forgive me

Reply With Quote
  #9  
Old June 3rd, 2007, 04:16 PM
Mittineague's Avatar
Mittineague Mittineague is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jul 2005
Location: West Springfield, Massachusetts
Posts: 552 Mittineague User rank is Private First Class (20 - 50 Reputation Level)Mittineague User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 1 m 33 sec
Reputation Power: 13
GET var

That doesn't make sense to me. If the source view of the page with the link:
print ("<tr><td><a href=morder.php");
print ("?p_id=");
print($row['id']);
print(">");
print($row['p_name']);
print("</a></td>");
shows a value, then $p_id = $_GET['p_id']; should work OK when the link is clicked. If you
echo $_GET['p_id'] it's empty?
The only thing I can think of that would do this is if you were working with an app that stripped out non-app variables.

Last edited by Mittineague : June 3rd, 2007 at 04:29 PM.

Reply With Quote
  #10  
Old June 3rd, 2007, 04:23 PM
TerraTuner TerraTuner is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 11 TerraTuner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 33 m 35 sec
Reputation Power: 0
Problem beeing:

Quote:
Originally Posted by Mittineague
That doesn't make sense to me. If the source view of the page with the link:
print ("<tr><td><a href=morder.php");
print ("?p_id=");
print($row['id']);
print(">");
print($row['p_name']);
print("</a></td>");
shows a value, then $p_id = $_GET['p_id']; should work OK when the link is clicked. If you
echo $_GET['p_id'] it's empty?
The only thing I can think of that would do this is if you were working with some sort of templating app that stripped out non-app variables.


So your problem is that your script does'nt generate the hyperlinks you wish with url and linkname from the database..?

Reply With Quote
  #11  
Old June 3rd, 2007, 10:32 PM
gavy gavy is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2007
Posts: 31 gavy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 29 m 42 sec
Reputation Power: 11
ok here: at thend i came to get:

that

So your problem is that your script does'nt generate the hyperlinks you wish with url and linkname from the database..? Today 03:16 PM

well as i said the below is the link but it is fetching the result from the database as i sho here:

$q1="SELECT * FROM catalog";
$r1=mysql_query($q1);
while($row=mysql_fetch_array($r1))
{
print ("<tr><td><a href=morder.php");
print ("?p_id=");
print($row['id']);
print(">");
print($row['p_name']);
print("</a></td>");
}

p_id is not the value coming from database, i have used it to make a link work.

dataqbase include the id, name, pic, desc fielsd.

hope this helps in solving the question of mine, thanks

Reply With Quote
  #12  
Old June 4th, 2007, 11:08 AM
Mittineague's Avatar
Mittineague Mittineague is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jul 2005
Location: West Springfield, Massachusetts
Posts: 552 Mittineague User rank is Private First Class (20 - 50 Reputation Level)Mittineague User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 1 m 33 sec
Reputation Power: 13
where's the bug?

Quote:
Originally Posted by gavy
the link but it is fetching the result from the database
Quote:
Originally Posted by gavy
p_id is not the value coming from database
Does
PHP Code:
<tr><td><a href=morder.php?p_id=$row['id']>$row['p_name']</a></td
Show results from the database for $row['id'] and $row['p_name'] or not?

Reply With Quote
  #13  
Old June 4th, 2007, 11:51 AM
gavy gavy is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2007
Posts: 31 gavy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 29 m 42 sec
Reputation Power: 11
you saying i should try to out the id and p_name if tht's the case they are doing well, also the link had started gebnerating the id but not passed to the next page variable li

select * from catalog where id='$p_id';

i think what i mean is this

Reply With Quote
  #14  
Old June 4th, 2007, 04:41 PM
Mittineague's Avatar
Mittineague Mittineague is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jul 2005
Location: West Springfield, Massachusetts
Posts: 552 Mittineague User rank is Private First Class (20 - 50 Reputation Level)Mittineague User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 1 m 33 sec
Reputation Power: 13
GET var

Is there an htaccess file that changes requests with GET variables? eg. "user friendly" URLs.
For example, when you go to the morder.php page, does the text in the browser's adress bar look like
... /morder.php?p_id=3
or more like
... /morder.php/3/

Last edited by Mittineague : June 4th, 2007 at 04:48 PM.

Reply With Quote
  #15  
Old June 4th, 2007, 08:05 PM
gavy gavy is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2007
Posts: 31 gavy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 29 m 42 sec
Reputation Power: 11
no my friend

Reply With Quote
  #16  
Old June 5th, 2007, 12:14 AM
Mittineague's Avatar
Mittineague Mittineague is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jul 2005
Location: West Springfield, Massachusetts
Posts: 552 Mittineague User rank is Private First Class (20 - 50 Reputation Level)Mittineague User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 1 m 33 sec
Reputation Power: 13
losing GET val

So you're saying that the URL in the address bar looks like:
... morder.php?p_id=3
yet when you
echo $_GET['p_id'];
the value is empty.

Reply With Quote
  #17  
Old June 5th, 2007, 01:51 AM
gavy gavy is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2007
Posts: 31 gavy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 29 m 42 sec
Reputation Power: 11
Quote:
Originally Posted by Mittineague
So you're saying that the URL in the address bar looks like:
... morder.php?p_id=3
yet when you
echo $_GET['p_id'];
the value is empty.


yes this the case, i id is picked up from databse but it does not pass value to next page i tried the above code of

echo $_GET['p_id'];
the value is empty....

now we are on right track

Reply With Quote
  #18  
Old June 5th, 2007, 10:18 AM
Mittineague's Avatar
Mittineague Mittineague is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jul 2005
Location: West Springfield, Massachusetts
Posts: 552 Mittineague User rank is Private First Class (20 - 50 Reputation Level)Mittineague User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 1 m 33 sec
Reputation Power: 13
losing GET value

Please post the code for that page from the beginning of the file to the echo $_GET line.
(don't forget to * out any db cnx info)

Reply With Quote
  #19  
Old June 5th, 2007, 06:02 PM
monkey56657 monkey56657 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Posts: 78 monkey56657 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 38 m 21 sec
Reputation Power: 12
Add me (or one of the others) on msn or ym or sumthing it may help lol.

mine is http://web-starters.net/includes/co...03366&Width=400
__________________



Reply With Quote
  #20  
Old June 5th, 2007, 10:35 PM
gavy gavy is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2007
Posts: 31 gavy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 29 m 42 sec
Reputation Power: 11
sorteed out by using $_request thanks everyone for yioour help

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > I think i will die


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap