Greenguy's Board


Go Back   Greenguy's Board > Programming & Scripting
Register FAQ Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 2003-09-10, 03:03 AM   #1
chaldoray
They have the Internet on computers, now?
 
Join Date: Sep 2003
Posts: 142
Problem In PHP..

Ok i am making a tracking script to track my users go here http://www.bishopbeater.com/trackingclicks.php it says

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /mnt2/users/jonhill/jonhill/bishopbeater.com/html/trackingclicks.php on line 5

heres my code for trackingclicks.php

<?
mysql_pconnect("mysql.4ph.com","jonhill","changeme");
mysql_select_db("counter");
$result = mysql_query("select * from counter WHERE url=\'$url\'");
while($r=mysql_fetch_array($result))
{
$id=$r["id"];
$count=$r["count"];
$url=$r["url"];
$count++;

$update = "UPDATE counter SET count=\'$count\' WHERE id=$id";
$updatesql = mysql_query($update);
?>
<script language="JavaScript">
document.location.href="<?php echo $url;?>"
</script>
<? } ?>

if anyone can help me id appreciate it thanks.
chaldoray is offline   Reply With Quote
Old 2003-09-11, 12:47 PM   #2
AcidMaX
Programming till my fingers bleed.
 
AcidMaX's Avatar
 
Join Date: Aug 2003
Location: Michigan
Posts: 876
Is $url being set? Are there any rows in the DB that have that URL? To me it seems like there is an error causing MySQL to barf. Maybe the url column name is wrong? Can you post the db layout?

Andy
AcidMaX is offline   Reply With Quote
Old 2003-09-11, 02:13 PM   #3
iSC_Luke
Aw, Dad, you've done a lot of great things, but you're a very old man, and old people are useless
 
Join Date: Aug 2003
Location: T.O.
Posts: 23
Send a message via ICQ to iSC_Luke
chaldoray,
It looks like either you don't connect to your DB Server successfully, or most likely, there is an error in your query.

Try this to see what the problem is:
PHP Code:
<? 
if ( mysql_pconnect("mysql.4ph.com","jonhill","changeme") === FALSE)
    echo 
"ERROR: Could Not Successfully Connect to DB Server<br>\nSQL ERROR:".mysql_error()."<br>\n";
if ( 
mysql_select_db("counter") === FALSE)
    echo 
"ERROR: Could Not Select Database<br>\nSQL ERROR:".mysql_error()."<br>\n";

if ( (
$result mysql_query("select * from counter WHERE url='$url'")) === FALSE)
    echo 
"ERROR: Error executing query:<br>\nSQL ERROR:".mysql_error()."<br>\n";

while(
$r=mysql_fetch_array($result)) 

$id=$r["id"]; 
$count=$r["count"]; 
$url=$r["url"]; 
$count++; 

$update "UPDATE counter SET count='$count' WHERE id=$id"
$updatesql mysql_query($update); 
?> 
<script language="JavaScript"> 
document.location.href="<?php echo $url;?>
</script> 
<? ?>
Hope this helps
__________________
<table width="100%" cellpadding="0" cellspacing="0"><tr><td width="100%"><a href="http://www.isharecash.com/refisc.php?a=i100"><img src="http://www.isharecash.com/promo/isharecash/banners/120x60_isc1.gif" border=0></a></td><td><img src="http://www.isharecash.com/G/sigs/bm.jpg" border=0"></td></tr></table><font face="Terminal" size=1 style="text-decoration:none">Weekly Payouts &nbsp;&copy;&nbsp; Top-Converting Niche Sites.</font>
iSC_Luke is offline   Reply With Quote
Old 2003-09-11, 02:19 PM   #4
iSC_Luke
Aw, Dad, you've done a lot of great things, but you're a very old man, and old people are useless
 
Join Date: Aug 2003
Location: T.O.
Posts: 23
Send a message via ICQ to iSC_Luke
This code won't execute the script if there is an error with the SQL Query:
PHP Code:
<? 
if ( mysql_pconnect("mysql.4ph.com","jonhill","changeme") === FALSE)
    echo 
"ERROR: Could Not Successfully Connect to DB Server<br>\nSQL ERROR:".mysql_error()."<br>\n";
if ( 
mysql_select_db("counter") === FALSE)
    echo 
"ERROR: Could Not Select Database<br>\nSQL ERROR:".mysql_error()."<br>\n";

if ( (
$result mysql_query("select * from counter WHERE url='$url'")) === FALSE)
    echo 
"ERROR: Error executing query:<br>\nSQL ERROR:".mysql_error()."<br>\n";
else {
    while(
$r=mysql_fetch_array($result)) { 
        
$id=$r["id"]; 
        
$count=$r["count"]; 
        
$url=$r["url"]; 
        
$count++; 
        
        
$update "UPDATE counter SET count='$count' WHERE id=$id"
        
$updatesql mysql_query($update); 
?> 
    <script language="JavaScript"> 
    document.location.href="<?php echo $url;?>
    </script> 
<?
    
}
}
?>
__________________
<table width="100%" cellpadding="0" cellspacing="0"><tr><td width="100%"><a href="http://www.isharecash.com/refisc.php?a=i100"><img src="http://www.isharecash.com/promo/isharecash/banners/120x60_isc1.gif" border=0></a></td><td><img src="http://www.isharecash.com/G/sigs/bm.jpg" border=0"></td></tr></table><font face="Terminal" size=1 style="text-decoration:none">Weekly Payouts &nbsp;&copy;&nbsp; Top-Converting Niche Sites.</font>
iSC_Luke is offline   Reply With Quote
Old 2003-09-11, 06:19 PM   #5
chaldoray
They have the Internet on computers, now?
 
Join Date: Sep 2003
Posts: 142
What's a good script to track what links your surfers are clicking any good ones out their? If so please tell me, Also what are some good sites to learn more about php function like if else, etc.
chaldoray is offline   Reply With Quote
Old 2003-09-11, 07:13 PM   #6
iSC_Luke
Aw, Dad, you've done a lot of great things, but you're a very old man, and old people are useless
 
Join Date: Aug 2003
Location: T.O.
Posts: 23
Send a message via ICQ to iSC_Luke
chaldoray,

Quote:
What's a good script to track what links your surfers are clicking any good ones out their? If so please tell me
Don't know of any free scripts for that, but they must be out there - keep looking - There are gazzilions of free scripts out there.

Quote:
Also what are some good sites to learn more about php function like if else, etc.
If you would like to learn PHP, it's probably best to get a book, however if you need reference to PHP functions, http://www.php.net/ is your best bet. It has the entire PHP manual right there, which you can search.

P.S. 'if' and 'else' are not functions, but language conditional statements. - some info about them can be found here: http://ca2.php.net/else

Good Luck!
__________________
<table width="100%" cellpadding="0" cellspacing="0"><tr><td width="100%"><a href="http://www.isharecash.com/refisc.php?a=i100"><img src="http://www.isharecash.com/promo/isharecash/banners/120x60_isc1.gif" border=0></a></td><td><img src="http://www.isharecash.com/G/sigs/bm.jpg" border=0"></td></tr></table><font face="Terminal" size=1 style="text-decoration:none">Weekly Payouts &nbsp;&copy;&nbsp; Top-Converting Niche Sites.</font>
iSC_Luke is offline   Reply With Quote
Old 2003-09-11, 07:15 PM   #7
iSC_Luke
Aw, Dad, you've done a lot of great things, but you're a very old man, and old people are useless
 
Join Date: Aug 2003
Location: T.O.
Posts: 23
Send a message via ICQ to iSC_Luke
Here is another link explaining all about Control Structures

Hope this helps
__________________
<table width="100%" cellpadding="0" cellspacing="0"><tr><td width="100%"><a href="http://www.isharecash.com/refisc.php?a=i100"><img src="http://www.isharecash.com/promo/isharecash/banners/120x60_isc1.gif" border=0></a></td><td><img src="http://www.isharecash.com/G/sigs/bm.jpg" border=0"></td></tr></table><font face="Terminal" size=1 style="text-decoration:none">Weekly Payouts &nbsp;&copy;&nbsp; Top-Converting Niche Sites.</font>
iSC_Luke is offline   Reply With Quote
Old 2003-09-12, 12:12 AM   #8
chaldoray
They have the Internet on computers, now?
 
Join Date: Sep 2003
Posts: 142
Thanks man im ok in php but i want to learn more about the dates and srand function and stuff, i have the book php for the worldwide web and master php 4.1
chaldoray is offline   Reply With Quote
Old 2003-09-12, 03:43 AM   #9
matt
Trying is the first step towards failure
 
Join Date: Apr 2003
Location: Australia
Posts: 123
Send a message via ICQ to matt
I've found these resources quite useful in the past...

http://www.phpbuilder.com/
http://www.phpfreaks.com/



Matt
__________________
Link List Land - Linklist Creation, Design and Implementation.
matt is offline   Reply With Quote
Old 2003-09-12, 01:20 PM   #10
chaldoray
They have the Internet on computers, now?
 
Join Date: Sep 2003
Posts: 142
Hey matt, I submitted my free sites to your site pink n purple
chaldoray is offline   Reply With Quote
Old 2003-09-12, 03:37 PM   #11
RawAlex
Took the hint.
 
Join Date: Mar 2003
Posts: 5,597
Send a message via AIM to RawAlex
You should always check after a query to make sure you have actual results, by:

$num_rows = mysql_num_rows ($result);

You might have an issue where you are getting more than one row returned, and as a result, the fetch_array will fail because you need to fetch_row instead.

Alex
RawAlex is offline   Reply With Quote
Old 2003-09-13, 05:17 PM   #12
venturi
No offence Apu, but when they were handing out religions you must have been out taking a whizz
 
Join Date: Apr 2003
Location: An Oasis atop a High Desert Mesa
Posts: 282
Send a message via ICQ to venturi
Good point Alex!

Another tip is to always perform your own error handling. For example:
PHP Code:
<?php
$query 
"SELECT * FROM my_table WHERE my_field='some_value'";
// note that I preceed all mysql calls with @ to supress the default error handling
$result = @mysql_query($query);
// now I am testing to see if I get a valid result
if ( ! $result) {
  echo @
mysql_error();
  break;
}

// now I process the results
while ($my_row = @mysql_fetch_assoc($result)) {
  
// here I do something spectacular with the data
}
?>
venturi is offline   Reply With Quote
Old 2003-09-13, 05:49 PM   #13
chaldoray
They have the Internet on computers, now?
 
Join Date: Sep 2003
Posts: 142
Can you explain all that to me? Like how would i call my host and db and check it if its in db if its not give them a error and the code to check if they submitted a form etc, how can i learn more about the mktime like 3000 i want to learn more about date and times and such thanks.
chaldoray is offline   Reply With Quote
Old 2003-09-13, 06:19 PM   #14
venturi
No offence Apu, but when they were handing out religions you must have been out taking a whizz
 
Join Date: Apr 2003
Location: An Oasis atop a High Desert Mesa
Posts: 282
Send a message via ICQ to venturi
Hop over to Script School and take TDavid's 16 part (you set the pace) course on PHP. That's where I started learning PHP and now it's what I do for my living. The course if free and full of information on most if not all of the questions you have.

Then hop over to amazon.com and grab a copy of this book: PHP Functions Essential Reference by Greant, Merral, Wilson & Michlitsch; published by New Riders. It's a great reference manual and is organized a bit more logically than the php.net manuals. I've had my copy for about 6 months now and I'm probably going to have to get a new copy of it by year's end because I've used and abused it so much.
venturi is offline   Reply With Quote
Old 2003-09-14, 02:43 AM   #15
chaldoray
They have the Internet on computers, now?
 
Join Date: Sep 2003
Posts: 142
Thanks man, I well go ahead and do that i already have php for the worldwide web book but it sucks is that book any good?
chaldoray is offline   Reply With Quote
Old 2003-09-14, 12:21 PM   #16
RawAlex
Took the hint.
 
Join Date: Mar 2003
Posts: 5,597
Send a message via AIM to RawAlex
Venturi, in the case of this code, I don't think the error is a "no result" rather too many results. fetch_array doesn't like working much when there are multiple rows in the result (need to fetch_row).

Just doing:

$nums = mysql_num_rows($result);
print $nums;

will show how many rows are selected in the database. That would go a long way to explain what is happening after.

Alex
RawAlex is offline   Reply With Quote
Old 2003-09-14, 11:54 PM   #17
chaldoray
They have the Internet on computers, now?
 
Join Date: Sep 2003
Posts: 142
Anymore else i can learn? More of the functions so i can create my own scripts
chaldoray is offline   Reply With Quote
Old 2003-09-15, 01:26 AM   #18
RawAlex
Took the hint.
 
Join Date: Mar 2003
Posts: 5,597
Send a message via AIM to RawAlex
I have SAMS PHP in 24 hours... it is actually quite useful. Admittedly, I have been programming other languages since, well, a long f-ing time, so maybe it just makes more sense to me. I have had a couple of php books, and this is the one that stays on my desk for reference.

php.net is a good place to get info on commands and comments from end users.

Alex
RawAlex is offline   Reply With Quote
Old 2003-09-15, 01:34 AM   #19
chaldoray
They have the Internet on computers, now?
 
Join Date: Sep 2003
Posts: 142
I have a couple of questions, i well be using php.net for functions how can i search new function in php.net? I am going to buy another book i have mastering php 4.1 now its a ok book.

Ok now, I made a login and stuff on my page, this is how i want it whenever someone clicks a link on my page pop-ups well come up if their not a registered user so they have to sign up to look at the page then when they sign up and login then when they go to a page they don't get the pop-ups and the page well show how can i do this in php?

How can you do that with .htaccess to so if your not a member on everypage you go pop-ups well come up until u register?
chaldoray is offline   Reply With Quote
Old 2003-09-15, 07:28 AM   #20
matt
Trying is the first step towards failure
 
Join Date: Apr 2003
Location: Australia
Posts: 123
Send a message via ICQ to matt
Quote:
Originally posted by chaldoray
I have a couple of questions, i well be using php.net for functions how can i search new function in php.net?
I search for everything on php.net by typing in urls like this

php.net/fopen
php.net/while

That'll take you straight to the page you're looking for and it'll also list a heap of other functions in the menu.


btw thanks for submitting
__________________
Link List Land - Linklist Creation, Design and Implementation.
matt is offline   Reply With Quote
Old 2003-09-15, 05:55 PM   #21
chaldoray
They have the Internet on computers, now?
 
Join Date: Sep 2003
Posts: 142
I just bought 2 php books from borders. PHP ADVANCED FOR THE WORLD WIDE WEB, and sams teach yourself php in 24 hours, BTW, i can return the books in 30 days and get a refund, so I'm going to read them in like a week then return them cool huh? I have 2 old php books that im going to sell on ebay.
chaldoray is offline   Reply With Quote
Old 2003-09-15, 05:58 PM   #22
chaldoray
They have the Internet on computers, now?
 
Join Date: Sep 2003
Posts: 142
What are some good marketing books i can pick up and read?
chaldoray is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:01 AM.


Mark Read
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc