Need some help from someone who knows .PHP
The code I have below works on an older version of .php however our web hosting company is planning to upgrade to the latest version of .php. This code does not work on the latest release. Can someone help me fix it? Thanks!
<Database Connection Call Appears Here>
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Oops some thing went wrong");
mysql_select_db($mysql_database, $bd) or die("Oops some thing went wrong");// we are now connected to database
$result = mysql_query("SELECT * FROM `OklahomaNRA` WHERE `id` ORDER BY RAND() LIMIT 15"); // selecting data through mysql_query()
echo '<table border=0px>'; // opening table tag
echo'<th>Subject</th><th>Url</th>'; //table headers
while($data = mysql_fetch_array($result))
{
// we are running a while loop to print all the rows in a table
echo '<table style="font-size:12px; font-family:Arial; color:black;">';
echo'<tr>'; // printing table row
echo '<td>'.$data['Subject'].'</td><td><a href="'.$data['Url'].'">'.$data['Url'].'</a></td></td> '; // we are looping all data to be printed till last row in the table
echo'</tr>'; // closing table row
}
?>
SQL Query
SQL Query
David Streb
dave@level1firearms.com
dave@level1firearms.com
Re: SQL Query
I'm no expert in php but have experienced a similar problem. The answer was to update the MySQL functions to MySQLi, so change mysql_connect to mysqli_connect and mysql_query to mysqli_query.
If that doesn't work then maybe someone else can step in.
Brian
If that doesn't work then maybe someone else can step in.
Brian
Re: SQL Query
It’s not as simple as just adding the i to mysql.
Perhaps the following post might help.
http://www.wysiwygwebbuilder.com/forum/ ... li#p419295
Perhaps the following post might help.
http://www.wysiwygwebbuilder.com/forum/ ... li#p419295
Re: SQL Query
Thanks for the reply's; still not working. The guy from GoDaddy told me I was using retired/depreciated calls. Does that help?
David Streb
dave@level1firearms.com
dave@level1firearms.com
Re: SQL Query
So are you now using mysqli instead of mysql where appropriate in the correct format?
In what way is it still not working?
In what way is it still not working?
Re: SQL Query
mysql_connect()
mysql_fetch_array()
mysql_query()
mysql_select_db()
These extensions were deprecated in PHP 5.5.0, and removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used.
mysql_fetch_array()
mysql_query()
mysql_select_db()
These extensions were deprecated in PHP 5.5.0, and removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used.
Re: SQL Query
Hi HankRock:
Thank you for the reply. I'm not a DB guy, this is the only call we make from the website. If I'm reading this correctly, I just need to change the "MySql" calls to "MySqli"?
The correct coding would be:
<Database Connection Call Appears Here>
$bd = mysqli_connect($mysqli_hostname, $mysqil_user, $mysqli_password) or die("Oops some thing went wrong");
mysqli_select_db($mysqli_database, $bd) or die("Oops some thing went wrong");// we are now connected to database
$result = mysqli_query("SELECT * FROM `OklahomaNRA` WHERE `id` ORDER BY RAND() LIMIT 15"); // selecting data through mysql_query()
echo '<table border=0px>'; // opening table tag
echo'<th>Subject</th><th>Url</th>'; //table headers
while($data = mysqi_fetch_array($result))
{
// we are running a while loop to print all the rows in a table
echo '<table style="font-size:12px; font-family:Arial; color:black;">';
echo'<tr>'; // printing table row
echo '<td>'.$data['Subject'].'</td><td><a href="'.$data['Url'].'">'.$data['Url'].'</a></td></td> '; // we are looping all data to be printed till last row in the table
echo'</tr>'; // closing table row
}
?>
Thank you for the reply. I'm not a DB guy, this is the only call we make from the website. If I'm reading this correctly, I just need to change the "MySql" calls to "MySqli"?
The correct coding would be:
<Database Connection Call Appears Here>
$bd = mysqli_connect($mysqli_hostname, $mysqil_user, $mysqli_password) or die("Oops some thing went wrong");
mysqli_select_db($mysqli_database, $bd) or die("Oops some thing went wrong");// we are now connected to database
$result = mysqli_query("SELECT * FROM `OklahomaNRA` WHERE `id` ORDER BY RAND() LIMIT 15"); // selecting data through mysql_query()
echo '<table border=0px>'; // opening table tag
echo'<th>Subject</th><th>Url</th>'; //table headers
while($data = mysqi_fetch_array($result))
{
// we are running a while loop to print all the rows in a table
echo '<table style="font-size:12px; font-family:Arial; color:black;">';
echo'<tr>'; // printing table row
echo '<td>'.$data['Subject'].'</td><td><a href="'.$data['Url'].'">'.$data['Url'].'</a></td></td> '; // we are looping all data to be printed till last row in the table
echo'</tr>'; // closing table row
}
?>
David Streb
dave@level1firearms.com
dave@level1firearms.com
Re: SQL Query
Did you see my previous posts?
The calls are still in the wrong format.
E.g. should be: $result = mysqli_query($db, "......");
and mysqli_select_db($db, $mysql_database)
The calls are still in the wrong format.
E.g. should be: $result = mysqli_query($db, "......");
and mysqli_select_db($db, $mysql_database)