Hello guys i recently moved a site to a new server and as soon as i did that i get the following error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/name/public_html/domain.com/admin/dis_report_view.php on line 29 The code there is <?php echo '<table class="blackwhite">'; echo "<tr><th colspan='2'>Report for: " . $row['name'] . "</th></tr>"; $query = mysql_query("SELECT domain_of_url(dis_reports.link) AS link from dis_reports WHERE dis_reports.gid = $gid"); while ($row2 = mysql_fetch_array($query)){ //line 29 echo "<tr><td class='darkcell'>" . $row2['link'] . "</td><td class='lightcell'>Submitted Successfully</td></tr>"; } echo "</table>"; ?> ----------- Second problem When i try to input some data on a form i get this Parse error: syntax error, unexpected T_STRING in /home/name/public_html/domain.com/admin/includes/dis.php on line 17 <?php if ($login_status != 1) exit(); if ($_POST['id'] != 0) { $link = htmlspecialchars($_POST['link']); echo $name; mysql_query("UPDATE dis_links SET link='$link' WHERE id='$_POST[id]'"); } else { $domainName = GetDomain($_POST['link']); mysql_query("SELECT id FROM dis_links WHERE domain_of_url(link)='$domainName'") mysql_query("INSERT INTO dis_links (link) ///LINE 17 VALUES ('$_POST[link]')") or die ('There was a MySql error when adding the link: '.mysql_error()); $newid = mysql_insert_id(); $url = $_POST['link']; echo '<div id="category-'.$newid.'" class="manage_item_new"><div class="manage_column0">'.$newid.'</div><div id="category-name-'.$newid.'" class="manage_column"><a href="'.$url.'" class="manage_link">'.$_POST['link'].'</a></div><div class="manage_column3" id="delete-image-'.$newid.'"><img src="images/delete.png" width="24" height="24" onclick="DeleteAsk('.$newid.');"></div><div class="manage_column3" id="edit-image-'.$newid.'"><img src="images/edit.png" width="24" height="24" onclick="EditCategory('.$newid.', '; echo "'".$_POST['link']."'"; echo ');"></div> <div id="edit-category-'.$newid.'" class="edit_game_container"></div></div>'; } function GetDomain($url) { $nowww = ereg_replace('www\.','',$url); $domain = parse_url($nowww); if(!empty($domain["host"])) { return $domain["host"]; } else { return $domain["path"]; } } ?> Could somebody have a look and tell me whats wrong?
Did your query run correctly? i.e. $query = mysql_query("SELECT domain_of_url(dis_reports.link) AS link from dis_reports WHERE dis_reports.gid = $gid"); Try echoing the sql and running it via phpMyAdmin or your sql client: echo "SELECT domain_of_url(dis_reports.link) AS link from dis_reports WHERE dis_reports.gid = $gid"; I think your second issue is due to the structure of the sql, '$_POST[link]' will likely be interpreted as $_POST variable instead of $_POST['link']. Try like this: ... VALUES ('".$_POST['link']."')") or ....
You should also escape anything before it hits the db. http://php.net/manual/en/function.mysql-real-escape-string.php