introduction screenshots faq forum blog modules components download
Please use the search function and/or read the FAQ first.

Go to Topic: PreviousNext
Go to: Message ListNew TopicSearchLog InPrint View

scripts not running



Posted by: daverego1982
September 07, 2009 04:56PM
HI,

i have recently installed easy php 5.3.0 , but i seem to have a problem with the server running php scripts with the database.
I know that the database has connected properly because when i view the php page in my browser it is drawing information from the database, however when i ask it to process a mysql query, nothing happens.

is there something wrong in my configuration, because i if there is an error i should be getting a mysql error when i click submit buttons if it has failed.

if anyone knows anything to help i would be very grateful.

may thanks

dr
Options: ReplyQuote
Posted by: Amour
September 08, 2009 12:27AM
I think a simple mysql_query() don't show anything with browser... can we see your code ?
Options: ReplyQuote
Posted by: daverego1982
September 08, 2009 06:40AM
sure i will post it up when i get home from work.

seems strange it wont execute mysql_query() in a browser. how the hell am i supposed to see the fruits of my newly aquired skills!
Options: ReplyQuote
Posted by: daverego1982
September 08, 2009 10:18PM
THE PHP I HAVE ENTERED IS AS BELOW AND LIKE I SAID WORKS FINE BUT IS NO PROCESSING. I HOPE YOU CAN SHED SOME LIGHT FOR ME!! I AM USING FIREFOX BROWSER TO TRY AND VIRE IT.

----------------------------------------------------------------------------------

<?php // sqltest.php
require_once 'login.php';
$db_server = mysql_connect($db_hostname, $db_username, $db_password);

if (!$db_server) die("unable to connect to MySQL: " . mysql_error());

mysql_select_db($db_database, $db_server)
or die("unable to select database: " . mysql_error());

if (isset($POST['author']) &&
isset($POST['title']) &&
isset($POST['category']) &&
isset($POST['year']) &&
isset($POST['isbn']))

{
$author = get_post('author');
$title = get_post('title');
$category = get_post('category');
$year = get_post('year');
$isbn = get_post('isbn');

if (isset($_POST['delete']) && $isbn != "")
{
$query = "DELETE FROM classics WHERE isbn='$isbn'";

if (!mysql_query($query, $db_server))
echo "DELETE Failed: $query<br />" .
mysql_error() . "<br /><br />";
}
else
{
$query = "INSERT INTO classics VALUES" . "('$author', '$title', '$category', '$year', '$isbn')";

if (!mysql_query($query, $db_server))
echo "INSERT Failed: $query<br />" .
mysql_error() . "<br /><br />";
}
}

echo <<<_END
<form action="sqltest.php" method ="post"><pre>
Author <input type="text" name="author" />
Title <input type="text" name="title" />
Category <input type="text" name="category" />
Year <input type="text" name="year" />
ISBN <input type"text" name ="isbn" />
<input type="submit" value="ADD RECORD" />
</pre></form>
_END;

$query = "SELECT * FROM classics";
$result = mysql_query($query);

if (!$result) die ("Database access failed: " . mysql_error());
$rows = mysql_num_rows($result);

for ($j = 0 ; $j < $rows ; ++$j)
{
$row = mysql_fetch_row($result);
echo <<<_END
<pre>
Author $row[0]
Title $row[1]
Category $row[2]
Year $row[3]
ISBN $row[4]
</pre>

<form action="sqltest.php" method="post">
<input type="hidden" name="delete" value="yes" />
<input type="hidden" name="isbn" value="$row[4]" />
<input type="submit" value="DELETE RECORD" /></form>
_END;
}

mysql_close($db_server);

function get_post($var)
{
return mysql_real_escape_string($_POST[$var]);
}
?>

----------------------------------------------------------------------

MANY THANKS
Options: ReplyQuote
Posted by: Amour
September 08, 2009 11:25PM
OK, so it's not an EasyPHP problem, but programming... it's not the good forum
Help : try to run your SQL query directly into phpMyAdmin to see if it's OK ;)
Options: ReplyQuote


Go to: Message ListSearchLog In
Your Name: 
Your Email: 
Subject: 
Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.