PHP

Moderators: None (Apply to moderate this forum)
Number of threads: 1848
Number of posts: 5016

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
how to search mysql database by php code? Posted by litter on 3 May 2005 at 2:36 AM
Please go to the url below to understanding my question
http://www.allit.com.my/index1.php
at that page you can see a column call HotDeal, please click a link below it and try.
it will come with a pop up screen and show the error message.
please help me!!! show me how to search the database

Report
Re: how to search mysql database by php code? Posted by tvienti on 3 May 2005 at 8:11 AM
litter,

Could you embellish on your question? I clicked the link and got a generic SQL error, but without knowing what you're trying to do or what your SQL code is, it's hard to answer the question.

Generally speaking, "searching" an SQL database is done via the SELECT command. Example... Say you have a table called "products" containing a list of product data, each with a unique ID column called "productid". If you wanted to get a specific row, you'd format your query similar to: "SELECT * FROM products WHERE productid = 1;"

An excellent place to learn some beginning SQL skills, plenty to get you rolling, is: http://www.sqlcourse.com/

: Please go to the url below to understanding my question
: http://www.allit.com.my/index1.php
: at that page you can see a column call HotDeal, please click a link below it and try.
: it will come with a pop up screen and show the error message.
: please help me!!! show me how to search the database
:
:

Report
Re: how to search mysql database by php code? Posted by litter on 3 May 2005 at 7:37 PM
This is my code , is that any problem ?


<?
include('Connections/haha.php');

mysql_select_db("allit_allit");

// <a href=popup.php?id=134>my link</a>
$result = mysql_query("SELECT * FROM hotdeal WHERE id=" + $_GET["id"]) or die(mysql_error());

if(mysql_num_rows>0)
{
$row = mysql_fetch_array($result);

$str_name = $row["Brand"];
}


?>






Report
Re: how to search mysql database by php code? Posted by tvienti on 3 May 2005 at 8:27 PM
That doesn't help... can you show your db schema?

: This is my code , is that any problem ?
:
:
: <?
: include('Connections/haha.php');
:
: mysql_select_db("allit_allit");
:
: // <a href=popup.php?id=134>my link</a>
: $result = mysql_query("SELECT * FROM hotdeal WHERE id=" + $_GET["id"]) or die(mysql_error());
:
: if(mysql_num_rows>0)
: {
: $row = mysql_fetch_array($result);
:
: $str_name = $row["Brand"];
: }
:
:
: ?>
:
:
:
:
:
:
:

Report
Re: how to search mysql database by php code? Posted by skyDive on 3 May 2005 at 8:36 PM
String concatenation in php is done with the [.] character.
So change your query to:

$result = mysql_query("SELECT * FROM hotdeal WHERE id=" . $_GET["id"]) or die(mysql_error());


Report
Re: how to search mysql database by php code? Posted by litter on 4 May 2005 at 11:58 PM
Oh Thanks .
the problem is solve now .

: String concatenation in php is done with the [.] character.
: So change your query to:
:
: $result = mysql_query("SELECT * FROM hotdeal WHERE id=" . $_GET["id"]) or die(mysql_error());
:
:
:




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.