PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$result = mysql_query("SELECT * FROM settings") or die('There was an error in the query at line ' . __LINE__ . ' of the script: ' . mysql_error());
while ($row = mysql_fetch_array($result)) {
$settings[$row['name']] = $row['value'];
}
$result = mysql_query("SELECT * FROM settings") or die('There was an error in the query at line ' . __LINE__ . ' of the script: ' . mysql_error());
while ($row = mysql_fetch_array($result)) {
echo '<p>We are about to make an array var named $settings[<strong>' . $row['name'] . '</strong>] that has a value of ' . $row['value'] . '.</p>';
$settings[$row['name']] = $row['value'];
}
Also, make sure that the query that makes the $settings array is called before you use any of the $settings elements, or they will all be blank (and throw undefined index notices at you).
We are about to make an array var named $settings[] that has a value of .
From is 0 and max_results is ...
And the query is: SELECT * FROM comments ORDER BY Date DESC LIMIT 0,
There was an error in the query at line 62 of the script: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
I used a custom mysql function and because of the function the script was inefficent. The same query was used up to 4 times in the file. Thanks to help from some friends I optimized the code into its current form.
You are not getting from your settings table what you expect. It appears that there is not data in settings, or the field names are not properly referenced. What are the field names of the settings table (with exact case and spelling)?
Thinking about it, your settings table should have two fields: setting_name and setting_value. Then, for each row in the table, assign one of your settings as the setting_name and give it a value so your table output would look like this...
<?php
$result = mysql_query("SELECT * FROM settings") or die('There was an error in the query at line ' . __LINE__ . ' of the script : ' . mysql_error());
while ($row = mysql_fetch_array($result)) {
// REMOVE THIS LINE WHEN TESTING IS DONE!!!!
echo '<p>We are about to make an array var named $settings[<strong>' . $row['setting_name'] . '</strong>] that has a value of ' . $row['setting_value'] . '.</p>';
$settings[$row['setting_name']] = $row['setting_value'];
}
?>
Do a mysql dump of your settings table and data and post that information here. That is about the only way to see what is really happening in your table. But at this point, your settings setter will always return an empty set of settings because your are using field names that, as far as I know from what you are telling me, do not exist in the table.
//Query Settings Table
$result = mysql_query("SELECT * FROM settings");
while ($row = mysql_fetch_array($result)) {
$settings[$row['name']] = $row['value'];
}
//Query Colors table
$result = mysql_query("SELECT * FROM colors");
while ($row = mysql_fetch_array($result)) {
$colors[$row['name']] = $row['value'];
}
$result = mysql_query("SELECT * FROM images");
while ($row = mysql_fetch_array($result)) {
$images[$row['name']] = $row['value'];
}
$max_results = $row['maxshow'];
$from = ($page * $max_results);
But hey, you're trying to get $row['maxshow'] from images table, not from settings table. Move the assignment of $max_results right after the query to settings table (before doing any other query).