I have the STRANGEST problem...
I finished creating a page to edit a table in my database....... Tesed it.... OK! right! now, I want to create one that edits the SAME FIELDS (by name) just on another table....
Ctrl+A... Ctrl+N... Ctrl+V! now find and replace the table names....... done!#
Testing...... UUUUH???!?!?!?! Error:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /<path>/bsc/admin/editpage.php on line 77
WTF!!!??!?!?!
This is my code... last time I had not selected the DB (dohhh!) At the top of the page I connect to the DB (this page handles a form TWICE!!!):
// Require config
require('../config.php');
// If config has no password
if(empty($mysqlPassword)){
// Connect to DB without password
$mysqlConnect = mysql_connect($mysqlHost, $mysqlUser);
}
// If config HAS a password
else{
// Connect to DB with password
$mysqlConnect = mysql_connect($mysqlHost, $mysqlUser, $mysqlPassword);
}
// Select DB
mysql_select_db($mysqlDB);
// If a form has been submitted
if(isset($_POST[submit])){
// Get form data
$teamname = $_POST[team];
$newContent = $_POST[content];
$newDisplayName = $_POST[displayname];
}
....Processes one form (sending stuff to the D😎....
else{
// Create form
// Prepare query
$getContent = 'SELECT displayname, content FROM ' . $mysqlTablePrefix . 'content WHERE teamname = \'' . $teamname . '\'';
// Run query
$getContentResults = mysql_query($getContent);
// Print into form
while($content = mysql_fetch_assoc($getContentResults)){ // LINE 77
printf("Display Name: <input type=\"text\" name=\"displayname\" value=\"%s\" /><br />\nInfo:<br />\n<textarea name=\"content\" rows=\"10\" cols=\"40\">%s</textarea><br /><br />", $content[displayname], $content[content]);
}
echo '<input type="hidden" name="team" value="' . $teamname . '" />' . "\n";
echo '<input type="submit" name="submit" value="Finish" />';
}
UUUHH?!??!?!?!! WTF is wrong????
This is SO weird because the same script (well.. different table name) STILL WORKS!!!