Closed Thread Icon

Topic awaiting preservation: Problem checking for exsisting data (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=29069" title="Pages that link to Topic awaiting preservation: Problem checking for exsisting data (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Problem checking for exsisting data <span class="small">(Page 1 of 1)</span>\

 
Trigger
Paranoid (IV) Inmate

From: Wales
Insane since: Jun 2002

posted posted 03-25-2007 21:56

Following my lyrics database project, I'm taking user-input and checking if the artist already exsists within the database. If it does the data is appended to the artists record of songs and if not the Artist is added to the database in theroy.

Unfortunatly, PHP is chucking all sorts of errors and killing the script, despite the lack of result being the desired effect.. It just isn't reacitng as I would of expected it too.

My code

code:
$query = "SELECT artist_name FROM artist WHERE artist_name = $artist";
        $sql = mysql_query($query);
        $result = mysql_num_rows($sql);



which out puts the following error

code:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource 

in /home/official/public_html/lyrics/submitlyrics.php on line 20

Unknown column 'Eminem' in 'where clause'



Now, I can't find the error after hours of looking and asking everyone I could think of.

The sql seems fine as "Unkown column 'Eminem'" seems to outline.

But, I can't check the number of rows? because its not a valid mysql result resource?

Where does my problem lie?

(Edited by Trigger on 03-25-2007 21:57)

Blacknight
Paranoid (IV) Inmate

From: INFRONT OF MY PC
Insane since: Dec 2001

posted posted 03-26-2007 00:00

$query = "SELECT artist_name FROM artist WHERE artist_name = $artist";

sorry for my lack of understanding if what i say is bull**** but shouldn't it be
WHERE artist_name=".$artist."; ?? or is this old fashioned code ???

hyperbole
Paranoid (IV) Inmate

From: Madison, Indiana
Insane since: Aug 2000

posted posted 03-26-2007 18:34

You need to put the artist name in quotes for SQL

code:
$query = "SELECT artist_name FROM artist WHERE artist_name = '$artist'"


Note the additional (') around $artist.

.



-- not necessarily stoned... just beautiful.

Trigger
Paranoid (IV) Inmate

From: Wales
Insane since: Jun 2002

posted posted 03-27-2007 01:56

Yeah, Thanks for that hyperbole. That resolved the issue.

« BackwardsOnwards »

Show Forum Drop Down Menu