The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
Please vote in the Forum Structure Poll. Polling will close at 2PM EST on January 21, 2025.

mysql error

Q_PrimeQ_Prime Registered User regular
edited May 2007 in Help / Advice Forum
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\bnb\confirmation.php on line 35

on this

$query = "SELECT visID, visRoomNum, UNIX_TIMESTAMP(visStartDate), UNIX_TIMESTAMP(visEndDate), visConfirmed FROM tblvisit WHERE visConfirmed = '0' AND visRoomNum=$roomNum";

$result = mysql_db_query('dbname', $query, $dbLink) or die(mysql_error());
while ($row = mysql_fetch_array($result))

i can't figure it out. because everything seems right when i look at the syntax and the table names and col names.

Q_Prime on

Posts

  • SpackleSpackle Registered User regular
    edited May 2007
    Try wrapping that variable $roomNum in single quotes.

    so "...AND visRoomNum = '$roomNum'";

    Spackle on
    Taco Bell does win the franchise war according to the tome of knowledge that is Demolition Man. However, I've watched Demolition Man more then a few times and never once did I see WoW. In conclusion Taco Bell has more lasting power then WoW.
    D&D Metal Thread: HERE
  • Q_PrimeQ_Prime Registered User regular
    edited May 2007
    nope :( same error. i have to run to work now but if anyone has any more suggestions please leave them and i'll try them when i get home.

    Q_Prime on
  • BradenBraden Registered User regular
    edited May 2007
    Q_Prime wrote: »
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\bnb\confirmation.php on line 35

    on this

    $query = "SELECT visID, visRoomNum, UNIX_TIMESTAMP(visStartDate), UNIX_TIMESTAMP(visEndDate), visConfirmed FROM tblvisit WHERE visConfirmed = '0' AND visRoomNum=$roomNum";

    $result = mysql_db_query('dbname', $query, $dbLink) or die(mysql_error());
    while ($row = mysql_fetch_array($result))

    i can't figure it out. because everything seems right when i look at the syntax and the table names and col names.

    $roomNum is a variable, so you need to have it outside the quotes of the string so that it reads whats in the variable instead of simply the variable name

    $query = "SELECT visID, visRoomNum, UNIX_TIMESTAMP(visStartDate), UNIX_TIMESTAMP(visEndDate), visConfirmed FROM tblvisit WHERE visConfirmed = '0' AND visRoomNum='" . $roomNum . "'";

    that way you put whatever is in $roomnum into the query string and also encapsulate it in single quotes.
    if you decide you need double quotes, which is what I think I did in my project, you'll need to use \"". $roomNum . "\""

    I believe that should help

    Braden on
    teh+emit.png
  • TheCapnTheCapn Registered User regular
    edited May 2007
    You need to use mysql_query instead of mysql_db_query. It's been deprecated.

    You'll also need to throw a mysql_select_db("dbname") in there before the query.

    Check the api at php.net, you can search by function name.

    TheCapn on
    Tacopants - a tasty comfortable combination.
  • LewishamLewisham Registered User regular
    edited May 2007
    Also... prepare your SQL statements, otherwise you are vunerable to SQL injection.

    Lewisham on
  • Q_PrimeQ_Prime Registered User regular
    edited May 2007
    okay i just got home i'm going to make these changes, also i should mention something funny about my error. everything i wanted the query to do was accomplished but i still received the error. i have not used sql in a long time so i dont know if that's common

    Q_Prime on
  • Q_PrimeQ_Prime Registered User regular
    edited May 2007
    oh wow, they changed around every way to connect to a db. interesting. now my server supports php 4. 3 will this be a problem?

    Q_Prime on
  • Q_PrimeQ_Prime Registered User regular
    edited May 2007
    i was getting the error because i had overwritten the variable named $query. i had used it twice for two different queries. weird. but its fixed now. thanks for the help

    Q_Prime on
Sign In or Register to comment.