Jump to content

Recommended Posts

OK...Before I begin, I should tell you that I just started learning php two days ago ( See, I'm only a designer)... So im not very good.... OK so I am building a yellowpages website that mimics dexknows.com or yellowpages.com in functionality (and just about everything else too)...And this is the code I have so far, but it pop ups with an errror... Any help would be greatly appreciated...Thanks:

 

<?php

$con = mysql_connect("localhost","root","");

if (!$con)

{

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

}

 

mysql_select_db("general", $con);

 

$var = @$_POST['search'];

$trimmed = trim($var);

if ($trimmed == "")

{

echo "<p>Please enter a search...</p>";

exit;

}

 

 

$query = "SELECT * FROM gjbusinesses where name like \"%$trimmed%\" OR description like \"%$trimmed%\";

 

$result = mysql_query($query);

 

while($row = mysql_fetch_array($result))

{

echo $row['name'];

echo $row['phone'];

echo $row['address1];

echo $row['website'];

echo "Description:";

echo " ";

echo $row['description'];

echo "</strong>";

echo "<hr>";

echo "</hr>";

echo "<br />";

}

?>

Link to comment
https://forums.phpfreaks.com/topic/213307-need-serious-help/
Share on other sites

What's the error?

 

I'm hoping you removed the root password on the code you posted and it's not blank. You also shouldn't use root to connect to your db.

 

If you can put your code in the PHP tag (PHP button in the toolbar) it would be much easier to read =)

Link to comment
https://forums.phpfreaks.com/topic/213307-need-serious-help/#findComment-1110626
Share on other sites

$var = @$_POST['search'];
$trimmed = trim($var);
if ($trimmed == "")
{
echo "<p>Please enter a search...</p>";
exit;
}


$query = "SELECT * FROM gjbusinesses where name like \"%$trimmed%\" OR description like \"%$trimmed%\";

$result = mysql_query($query);

 

SQL Injection vulnerability there. See mysql_real_escape_string().

Link to comment
https://forums.phpfreaks.com/topic/213307-need-serious-help/#findComment-1110661
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.