Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Major MySQL Troubles

Major MySQL Troubles
Thread Tools
RGB
Mac Elite
Join Date: Jan 2002
Location: College in the Land of Oz
Status: Offline
Reply With Quote
Jul 8, 2003, 04:39 AM
 
Hey all -

I'm currently developing a website for a client of mine, and using a test database being served up by MySQL from my Powerbook (also the location of the Apache server) Suddenly, queries from PHP to the database come up empty. These queries used to work, but no longer do, yet they still work in phpMyAdmin.

For example, entering "SELECT * FROM `manufacturers` WHERE 1" in the SQL tab of phpMyAdmin correctly displays all rows from the table 'manufacturers'. Placing the same command in a while loop in a PHP file comes up empty.

An example PHP file with no frills would look like this:

Code:
<?php echo "hello\n" ; echo "<table>\n" ; $db = mysql_connect("127.0.0.1", "syab"); mysql_select_db("syab",$db); $result = mysql_query("SELECT * FROM manufacturers WHERE 1",$db); while ($myarray = mysql_fetch_array($result)) { printf("<tr bgcolor=\"#CCCCCC\"><td>%s</td><td>%s</td></tr>\n", $myarray[name], $myarray[description]) ; } echo "</table>\n" ; ?>
*i'll work on getting this to display after I get back from my meeting with the client.
(Last edited by RGB; Jul 8, 2003 at 08:15 AM. )
     
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status: Offline
Reply With Quote
Jul 8, 2003, 07:19 AM
 
ugh. you might wanna edit that post a bit, so it's not confusing the browser so much. it's making the page render all funny. use the [code] tag.
"Have sharp knives. Be creative. Cook to music" ~ maxelson
     
Fresh-Faced Recruit
Join Date: May 2001
Location: USA
Status: Offline
Reply With Quote
Jul 14, 2003, 08:13 PM
 
well, your post is a little weird and i can't see any code.

have you checked your webapp's mysql permissions?

try using mysql_error() to get some more info out of PHP.
     
Dedicated MacNNer
Join Date: Aug 2002
Status: Offline
Reply With Quote
Jul 14, 2003, 09:12 PM
 
the code as it was meant to show
[php]
<?php
echo "hello\n" ;
echo "<table>\n" ;
$db = mysql_connect("127.0.0.1", "syab");
mysql_select_db("syab",$db);
$result = mysql_query("SELECT * FROM manufacturers WHERE 1",$db);
while ($myarray = mysql_fetch_array($result)) {
printf("<tr bgcolor=\"#CCCCCC\"><td>%s</td><td>%s</td></tr>\n", $myarray[name], $myarray[description]) ;
}
echo "</table>\n" ;
?>
[/php]

--will
     
Dedicated MacNNer
Join Date: Aug 2002
Status: Offline
Reply With Quote
Jul 14, 2003, 09:14 PM
 
just a thought:

do you need to use

$myarray['name']

instead of

$myarray[name]

--will
     
RGB  (op)
Mac Elite
Join Date: Jan 2002
Location: College in the Land of Oz
Status: Offline
Reply With Quote
Jul 15, 2003, 02:14 AM
 
Some weird stuff happened with priveledges and whatnot on my database. Suddenly the username and password I was querying with weren't working. I found the appropriate name and password to access the database, and all is well in this department now.

That's not to say there aren't other troubles popping up my first database driven website. It's fun. I fix one thing, something else breaks / dies. Keeps me on my toes.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 03:47 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2