User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,667 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,932 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1265 | Replies: 4
Reply
Join Date: Jan 2007
Posts: 12
Reputation: mikesowerbutts is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
mikesowerbutts mikesowerbutts is offline Offline
Newbie Poster

Help mysql_fetch_array random problem?

  #1  
Apr 11th, 2007
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:

$sqlProject = "select * from project where ProjectName='.$pName.';";
                          $queryProject = mysql_query($sqlProject) or die("query Project error ");
                          $workType= Array();
                         
                          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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2005
Posts: 354
Reputation: DanceInstructor is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 12
DanceInstructor's Avatar
DanceInstructor DanceInstructor is offline Offline
Posting Whiz

Re: mysql_fetch_array random problem?

  #2  
Apr 12th, 2007
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)...
Clear Mind Hosting and Web Design

If I've helped you please consider adding to my reputation.
Reply With Quote  
Join Date: Jan 2007
Posts: 12
Reputation: mikesowerbutts is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
mikesowerbutts mikesowerbutts is offline Offline
Newbie Poster

Re: mysql_fetch_array random problem?

  #3  
Apr 12th, 2007
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
Reply With Quote  
Join Date: Mar 2004
Posts: 715
Reputation: Phaelax is on a distinguished road 
Rep Power: 6
Solved Threads: 28
Phaelax Phaelax is offline Offline
Master Poster

Re: mysql_fetch_array random problem?

  #4  
Apr 16th, 2007
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 5:29 pm.
Reply With Quote  
Join Date: Jan 2007
Posts: 12
Reputation: mikesowerbutts is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
mikesowerbutts mikesowerbutts is offline Offline
Newbie Poster

Re: mysql_fetch_array random problem?

  #5  
Apr 17th, 2007
cheers anyway dude!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 1:54 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC