CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Threaded View

  1. #1
    Join Date
    May 2007
    Posts
    72

    Exclamation Need help with MySQL...

    I have never liked MySQL as a storage method...
    In the past I have just used Plain Text files to bypass it...
    However my current project requires more security...

    anyhow here is the problem code...
    PHP Code:
    function search($select,$table,$row,$search,$row2=null,$search2=null){
    $x mysql_connect('localhost','root','root');
    mysql_select_db('root_bloodmadness',$x);
    if(
    $select == '') {$resource mysql_query("SELECT * FROM $table WHERE $row=`$search`",$x);}
    else if(!isset(
    $row2)){ $resource mysql_query("SELECT $select FROM $table WHERE $row=`$search`",$x);}
    else {
    $resource mysql_query("SELECT $select FROM $table WHERE $row=`$search` AND $row2=`$search2`",$x);}
    $result=mysql_fetch_row($resource);
    mysql_close($x);
    unset(
    $x);
    if(!isset(
    $result[1])){$result $result[0];}
    return 
    $result;
    }

    function 
    insert($table,$rows,$values) {
    $x mysql_connect('localhost','root','root');
    mysql_select_db('root_bloodmadness',$x);
    $result mysql_query("INSERT INTO $table($rows) VALUES($values)");
    mysql_close($x);
    unset(
    $x);
    return 
    $result;
    }

    function 
    update($table,$row,$value$row2,$find) {
    $x mysql_connect('localhost','root','root');
    mysql_select_db('root_bloodmadness',$x);
    $result mysql_query("UPDATE $table SET $row=$value WHERE $row2=$find");
    mysql_close($x);
    unset(
    $x);
    return 
    $result;

    [Fri Jan 14 08:44:08 2011] [error] [client 127.0.0.1] PHP Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in C:\\Users\\Alexander\\Documents\\UniServer\\www\\index.php on line 11, referer: http://localhost/index.php

    ^ I get this error a lot...

    With how many ways I modified the above code I am starting to suspect it may be a problem with the function call(I checked the functions and databases and they should work)...

    Thanks in advance for any effort made to assist me...
    Last edited by PeejAvery; January 14th, 2011 at 11:47 AM. Reason: Changed code to PHP tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured