icorange Posted April 29, 2008 Share Posted April 29, 2008 Hi everyone ... thank you in advance for looking at this ... I have a site ... uploading to GoDaddy hosting (MySQL version 5.0) ... I've tried so many things with my coding, changed it from mysqli to mysql ... and everything else, I'm a bit confused now ... when I upload all my files for a VERY simple subscription service, I keep getting this error: Fatal error: Call to undefined function: mysql_connect_errno() I have read a lot about this error - and have made so many changes, I think my coding is a bit scrambled now ... I would really appreciate the help!!! Thanks again ... <?php function doDB() { global $mysql; $mysql = mysql_connect('hostsite', 'user', 'password', 'dbname'); if (mysql_connect_errno()) { printf("Connect failed: %s\n", mysql_connect_error()); exit(); } } function emailChecker($email) { global $mysql, $check_res; $check_sql = "SELECT id FROM SUBSCRIPTION WHERE email = '".$email."'"; $check_res = mysql_query($mysql, $check_sql) or die(mysql_error($mysql)); } if (!$_POST) { $display_block = " <form method=\"POST\" action=\"".$_SERVER["PHP_SELF"]."\"> <p><strong>Your E-Mail Address:</strong><br/> <input type=\"text\" name=\"email\" size=\"40\" maxlength=\"150\"> <p><strong>Action:</strong><br/> <input type=\"radio\" name=\"action\" value=\"sub\" checked> subscribe <input type=\"radio\" name=\"action\" value=\"unsub\"> unsubscribe <p><input type=\"submit\" name=\"submit\" value=\"Submit Form\"></p> </form>"; } else if (($_POST) && ($_POST["action"] == "sub")) { if ($_POST["email"] == "") { header("Location: form.php"); exit; } else { doDB(); emailChecker($_POST["email"]); if (mysql_num_rows($check_res) < 1) { mysql_free_result($check_res); $add_sql = "INSERT INTO subscription (email) VALUES('".$_POST["email"]."')"; $add_res = mysql_query($mysql, $add_sql) or die(mysql_error($mysql)); $display_block = "<p>Thanks for signing up!</p>"; mysql_close($mysql); } else { $display_block = "<p>You're already subscribed!</p>"; } } } else if (($_POST) && ($_POST["action"] == "unsub")) { if ($_POST["email"] == "") { header("Location: form.php"); exit; } else { doDB(); emailChecker($_POST["email"]); if (mysql_num_rows($check_res) < 1) { mysql_free_result($check_res); $display_block = "<p>Couldn't find your address!</p> <p>No action was taken.</p>"; } else { while ($row = mysql_fetch_array($check_res)) { $id = $row["id"]; } $del_sql = "DELETE FROM subscription WHERE id = '".$id."'"; $del_res = mysql_query($mysql, $del_sql) or die(mysql_error($mysql)); $display_block = "<p>You're unsubscribed!</p>"; } mysql_close($mysql); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/103345-fatal-error-call-to-undefined-function-mysql_connect_errno/ Share on other sites More sharing options...
fenway Posted April 29, 2008 Share Posted April 29, 2008 mysql_connect_errno() or mysql_connect_error()? Quote Link to comment https://forums.phpfreaks.com/topic/103345-fatal-error-call-to-undefined-function-mysql_connect_errno/#findComment-529490 Share on other sites More sharing options...
icorange Posted April 29, 2008 Author Share Posted April 29, 2008 Hi! thanks .... copied right from the browser ... Fatal error: Call to undefined function: mysql_connect_errno() in ... Quote Link to comment https://forums.phpfreaks.com/topic/103345-fatal-error-call-to-undefined-function-mysql_connect_errno/#findComment-529535 Share on other sites More sharing options...
PFMaBiSmAd Posted April 29, 2008 Share Posted April 29, 2008 Like the error message states, there are no mysql functions by that/those names. There are a couple of mysqli functions by those names. Please read error messages. Quote Link to comment https://forums.phpfreaks.com/topic/103345-fatal-error-call-to-undefined-function-mysql_connect_errno/#findComment-529543 Share on other sites More sharing options...
fenway Posted April 29, 2008 Share Posted April 29, 2008 Hi! thanks .... copied right from the browser ... Fatal error: Call to undefined function: mysql_connect_errno() in ... It's not in the browser, it's in your code. There's a sticky in the child forum too. Quote Link to comment https://forums.phpfreaks.com/topic/103345-fatal-error-call-to-undefined-function-mysql_connect_errno/#findComment-529558 Share on other sites More sharing options...
icorange Posted April 29, 2008 Author Share Posted April 29, 2008 Hi ... thanks ... well I do understand that "mysql_connect_errno()" is in my code .... guess I'm just a little TOO new at this ... I used a "subscription.php" file right from Julie Meloni's third edition PHP, MySQL and Apache ... used it exactly ... hosting with GoDaddy - using Mysql 5.0 ... when I went to the site, entered an email ... the Fatal error came up in the browser ... I was then told to change all my "mysqli" to "mysql" ... same errors ... sorry for being so ignorant ... I just can't figure out what I am doing wrong :'( Quote Link to comment https://forums.phpfreaks.com/topic/103345-fatal-error-call-to-undefined-function-mysql_connect_errno/#findComment-529593 Share on other sites More sharing options...
fenway Posted April 29, 2008 Share Posted April 29, 2008 You can't switch to mysqli without enabling the extensions first. Quote Link to comment https://forums.phpfreaks.com/topic/103345-fatal-error-call-to-undefined-function-mysql_connect_errno/#findComment-529613 Share on other sites More sharing options...
icorange Posted April 29, 2008 Author Share Posted April 29, 2008 So then I would have to contact GoDaddy and have them enable these extensions since I have no control over the php.in file? yes? oh please, oh please ... Quote Link to comment https://forums.phpfreaks.com/topic/103345-fatal-error-call-to-undefined-function-mysql_connect_errno/#findComment-529639 Share on other sites More sharing options...
PFMaBiSmAd Posted April 29, 2008 Share Posted April 29, 2008 If your host does not have the mysqli extension enabled, they probably are not going to do it just because you ask. The equivalent mysql function to mysqli_connect_errno() would be mysql_errno() and the equivalent mysql function to mysqli_connect_error() would be mysql_error(). You cannot just remove or add the "i" to change code between mysqli and mysql. The parameter counts and parameter orders are different. For example, mysql_connect() in your posted code typically uses three parameters and the fourth is a flag to cause a new link to be created. mysqli_connect() uses the fourth parameter as the database. The mysql_query() parameters are actually reversed from the mysqli_query() parameters. Quote Link to comment https://forums.phpfreaks.com/topic/103345-fatal-error-call-to-undefined-function-mysql_connect_errno/#findComment-529725 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.