Jump to content

Recommended Posts

I am doing a project for school that requires a search function and i keep getting an error through putty that says: Undifined Offset 3 on line 25.

 

I am trying to search a database with keywords. By the way I do not really know how i would post the results.

 

Here is my code:

 

<html>

 

<body>

 

<form name="form" action="" method="POST">

Search: <input type="text" name="$s" /> <br />

<input type="submit" name="submitbutton" />

<input type="reset" name="resetbutton" />

</form>

 

<?php

 

 

// Connecting, selecting database

$link = mysql_connect('HOST', 'USERNAME', 'PASSWORD')

    or die('Could not connect: ' . mysql_error());

mysql_select_db('software') or die('Could not select database');

 

// Performing SQL query

$s = @$_GET['$s'] ;

$query = "SELECT * FROM Master WHERE Keyword = '$s' ";

$result = mysql_query($query) or die('Query failed: ' . mysql_error());

 

//printing results

print "RESULTS: $_POST[$result] ";  <---------THIS IS LINE 25

 

?>

 

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/85379-help-me-please/
Share on other sites

<html>
<body>
<form name="form" action="" method="POST">
Search: <input type="text" name="key" />
<input type="submit" name="submitbutton" />
<input type="reset" name="resetbutton" />
</form>

<?php


// Connecting, selecting database
$link = mysql_connect('HOST', 'USERNAME', 'PASSWORD')
    or die('Could not connect: ' . mysql_error());
mysql_select_db('software') or die('Could not select database');

// Performing SQL query
$s = @$_GET['$s'] ;
$query = "SELECT * FROM Master WHERE Keyword like '".$_POST['key']."' ";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
while($row= mysql_fetch_assoc($result)){
echo "RESULTS:". $_POST['field here'];// note put a proper field name on that array index 
}											// this are your table fields
?>

</body>
</html>

there and this is not MSSQL this is simple php mysql issue it should be on php help board

Link to comment
https://forums.phpfreaks.com/topic/85379-help-me-please/#findComment-436051
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.