 |
 |
Major MySQL Troubles
|
 |
|
 |
|
Mac Elite
Join Date: Jan 2002
Location: College in the Land of Oz
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
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
|
|
just a thought:
do you need to use
$myarray['name']
instead of
$myarray[name]
--will
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Jan 2002
Location: College in the Land of Oz
Status:
Offline
|
|
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.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|