Have some problems with the code that they gave me. Can anyone please let me know what is going wrong?
Here is the code:
[php]
<?php /*Program: mysql_send.php *Desc: PHP program that sends an SQL query to the * MySQL server and displays the results. */ echo " SQL Query Sender "; if(ini_get("magic_quotes_gpc") == "1") { $_POST['query'] = stripslashes($_POST['query']); } $host=""; $user=""; $password=""; /* Section that executes query and displays the results */ if(!empty($_POST['form'])) { mysql_connect($host,$user,$password); mysql_select_db($_POST['database']); $result = mysql_query($_POST['query']); echo "Database Selected: {$_POST['database']}Query: {$_POST['query']}
Results
"; if($result == false) { echo "
Error: ".mysql_error($cxn)."
"; } elseif(@mysql_num_rows($result) == 0) { echo "Query completed. No results returned.
"; } else { /* Display results */ echo "".mysql_field_name($result,$i). " | "; } echo "
---|
".$value." | "; } echo "
"; exit(); } /* Displays form for query input */ if (@$_POST['queryButton'] != "Edit Query") { $query = " "; } else { $query = str_replace("%&%","'",$_POST['query']); } ?>
Type in database name | > |
Type in SQL query | <?php echo $query ?> |
[/php]
Here is the error msg that I am getting:
Database Selected: Query: hi ResultsWarning: mysql_error(): supplied argument is not a valid MySQL-Link resource (( took out something for Secirty)) on line 28
Error:
**Mod Edit - Added PHP tags for better readability.