943,965 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 2611
  • PHP RSS
Apr 11th, 2007
0

mysql_fetch_array random problem?

Expand Post »
Hello all,

I have been using mysql_fetch_array to read data from a query to a php array so i can then use it on my webpage. Everything was going fine until now...

I cant see the problem with my code, but it keeps calling the or die() error handler when trying to get the array. here is the code:

PHP Syntax (Toggle Plain Text)
  1.  
  2. $sqlProject = "select * from project where ProjectName='.$pName.';";
  3. $queryProject = mysql_query($sqlProject) or die("query Project error ");
  4. $workType= Array();
  5.  
  6. while($proj = mysql_fetch_array($queryProject) or die("error in fetch array")){

the $pName variable is being passed to the sql statment fine and the mysql_query($sqlProject) statment isnt throwing any errors, but the mysql_fetch_array() is! it wont throw any mysql_error() messages in the die() handler, just a string to let me know something is wrong.

Does this mean its a php problem and not a mysql problem?

I am totally lost/confused with this... please help me!

thx

Mike
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mikesowerbutts is offline Offline
24 posts
since Jan 2007
Apr 12th, 2007
1

Re: mysql_fetch_array random problem?

Are you sure the query is returning results? Are the results an array?

print_r($sqlProject); so you know the query looks lik you think it should. Try running that query in phpMyAdmin and see what the results are, that may help you figure out what's going on.

You may need to add the resource link to the query: mysql_query($sqlProject, $link); This link is made using mysql_connect() so look for :

$somename = mysql_connect(login stuff...);

and then you wound want to have it:

$queryProject = mysql_query($sqlProject, $somename)...
Reputation Points: 17
Solved Threads: 14
Posting Whiz
DanceInstructor is offline Offline
355 posts
since Feb 2005
Apr 12th, 2007
0

Re: mysql_fetch_array random problem?

Hi there,

I managed to fix the problem. the $pName variable needed some white space trimming from the end and I used the LIKE %varname% operator instead of =.

cheers for the halp though
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mikesowerbutts is offline Offline
24 posts
since Jan 2007
Apr 16th, 2007
0

Re: mysql_fetch_array random problem?

Beat me to it. Was gonna say the problem is in the value of your pName variable which was likely causing an incorrect query string, hence no result.

ah bugger, this was over 4 days ago.
Last edited by Phaelax; Apr 16th, 2007 at 6:29 pm.
Reputation Points: 92
Solved Threads: 51
Practically a Posting Shark
Phaelax is offline Offline
856 posts
since Mar 2004
Apr 17th, 2007
0

Re: mysql_fetch_array random problem?

cheers anyway dude!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mikesowerbutts is offline Offline
24 posts
since Jan 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: PHP Quote form
Next Thread in PHP Forum Timeline: tidy





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC